Implement GetECConfig

This commit is contained in:
Spotlight 2020-12-23 05:05:18 -06:00
parent e0f676f1f5
commit 7558aeed43
No known key found for this signature in database
GPG Key ID: 874AA355B3209BDC
5 changed files with 33 additions and 7 deletions

View File

@ -1,6 +1,13 @@
<Config>
<!-- Web information -->
<Address>127.0.0.1:8080</Address>
<!-- Used to configure various relative URLs.
For example, given a Base URL of example.com,
ias.example.com, ecs.example.com, etc. will be
returned as a part of configuration. -->
<BaseURL>example.com</BaseURL>
<!-- Database configuration -->
<SQLAddress>127.0.0.1:3306</SQLAddress>
<SQLUser>username</SQLUser>
<SQLPass>password</SQLPass>

26
ecs.go
View File

@ -36,7 +36,6 @@ func ecsInitialize() {
}
func checkDeviceStatus(e *Envelope) {
// You need to POST some SOAP from WSC if you wanna get some, honey. ;3
e.AddCustomType(Balance{
Amount: 2018,
Currency: "POINTS",
@ -47,11 +46,10 @@ func checkDeviceStatus(e *Envelope) {
}
func notifyETicketsSynced(e *Envelope) {
// This is a disgusting request, but 20 dollars is 20 dollars. ;3
// TODO: Implement handling of synchronization timing
}
func listETickets(e *Envelope) {
fmt.Println("The request is valid! Responding...")
rows, err := ownedTitles.Query(e.AccountId())
if err != nil {
e.Error(2, "that's all you've got for me? ;3", err)
@ -89,14 +87,12 @@ func listETickets(e *Envelope) {
}
func getETickets(e *Envelope) {
fmt.Println("The request is valid! Responding...")
e.AddKVNode("ForceSyncTime", "0")
e.AddKVNode("ExtTicketTime", e.Timestamp())
e.AddKVNode("SyncTime", e.Timestamp())
}
func purchaseTitle(e *Envelope) {
// If you wanna fun time, it's gonna cost ya extra sweetie... ;3
e.AddCustomType(Balance{
Amount: 2018,
Currency: "POINTS",
@ -111,3 +107,23 @@ func purchaseTitle(e *Envelope) {
e.AddKVNode("TitleId", "00000000")
e.AddKVNode("ETickets", "00000000")
}
// genServiceUrl returns a URL with the given service against a configured URL.
// Given a baseUrl of example.com and genServiceUrl("ias", "IdentityAuthenticationSOAP"),
// it would return http://ias.example.com/ias/services/ias/IdentityAuthenticationSOAP.
func genServiceUrl(service string, path string) string {
return fmt.Sprintf("http://%s.%s/%s/services/%s", service, baseUrl, service, path)
}
func getECConfig(e *Envelope) {
contentUrl := fmt.Sprintf("http://ccs.%s/ccs/download", baseUrl)
e.AddKVNode("ContentPrefixURL", contentUrl)
e.AddKVNode("UncachedContentPrefixURL", contentUrl)
e.AddKVNode("SystemContentPrefixURL", contentUrl)
e.AddKVNode("SystemUncachedContentPrefixURL", contentUrl)
e.AddKVNode("EcsURL", genServiceUrl("ecs", "ECommerceSOAP"))
e.AddKVNode("IasURL", genServiceUrl("ias", "IdentityAuthenticationSOAP"))
e.AddKVNode("CasURL", genServiceUrl("cas", "CatalogingSOAP"))
e.AddKVNode("NusURL", genServiceUrl("nus", "NetUpdateSOAP"))
}

1
ias.go
View File

@ -57,7 +57,6 @@ func getChallenge(e *Envelope) {
// It then uses another hard-coded value in place of this returned value entirely in any situation.
// For this reason, we consider it irrelevant.
e.AddKVNode("Challenge", SharedChallenge)
}
func getRegistrationInfo(e *Envelope) {

View File

@ -35,6 +35,7 @@ const (
)
var db *sql.DB
var baseUrl string
// checkError makes error handling not as ugly and inefficient.
func checkError(err error) {
@ -68,6 +69,8 @@ func main() {
db.SetMaxOpenConns(10)
db.SetMaxIdleConns(10)
baseUrl = CON.BaseURL
// Initialize handlers.
ecsInitialize()
iasInitialize()
@ -84,7 +87,7 @@ func main() {
ecs.Authenticated("ListETickets", listETickets)
ecs.Authenticated("GetETickets", getETickets)
ecs.Authenticated("PurchaseTitle", purchaseTitle)
ecs.Unauthenticated("GetECConfig", getECConfig)
}
ias := r.HandleGroup("ias")

View File

@ -32,6 +32,7 @@ type Config struct {
XMLName xml.Name `xml:"Config"`
Address string `xml:"Address"`
BaseURL string `xml:"BaseURL"`
SQLAddress string `xml:"SQLAddress"`
SQLUser string `xml:"SQLUser"`