diff --git a/config.example.xml b/config.example.xml index 2efd098..de6037d 100644 --- a/config.example.xml +++ b/config.example.xml @@ -1,6 +1,13 @@ +
127.0.0.1:8080
+ + example.com + 127.0.0.1:3306 username password diff --git a/ecs.go b/ecs.go index c432fcf..66ae246 100644 --- a/ecs.go +++ b/ecs.go @@ -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")) +} diff --git a/ias.go b/ias.go index aeaa3a6..7bbaff9 100644 --- a/ias.go +++ b/ias.go @@ -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) { diff --git a/main.go b/main.go index 04b59e6..d22463b 100644 --- a/main.go +++ b/main.go @@ -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") diff --git a/structure.go b/structure.go index b0b2484..f3de0ae 100644 --- a/structure.go +++ b/structure.go @@ -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"`