Skip to content

Commit

Permalink
Merge pull request #185 from rod-hynes/master
Browse files Browse the repository at this point in the history
Pass inputs to psinet database lookups
  • Loading branch information
rod-hynes committed Jun 16, 2016
2 parents b1f4e75 + 11a4ec4 commit 6ce4c8f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
19 changes: 12 additions & 7 deletions psiphon/server/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ func handshakeAPIRequestHandler(
baseRequestParams)).Info("API event")

// TODO: share struct definition with psiphon/serverApi.go?
// TODO: populate response data using psinet database

var handshakeResponse struct {
Homepages []string `json:"homepages"`
UpgradeClientVersion string `json:"upgrade_client_version"`
Expand All @@ -117,19 +115,26 @@ func handshakeAPIRequestHandler(
ServerTimestamp string `json:"server_timestamp"`
}

// Ignoring errors as params are validated
sponsorID, _ := getStringRequestParam(params, "sponsor_id")
propagationChannelID, _ := getStringRequestParam(params, "propagation_channel_id")
clientVersion, _ := getStringRequestParam(params, "client_version")
clientPlatform, _ := getStringRequestParam(params, "client_platform")
clientRegion := geoIPData.Country

handshakeResponse.Homepages = psinetDatabase.GetHomepages(
"", "", "") // TODO: sponsorID, clientRegion, clientPlatform)
sponsorID, clientRegion, clientPlatform)

handshakeResponse.UpgradeClientVersion = psinetDatabase.GetUpgradeClientVersion(
"") // TODO: clientVersion)
clientVersion, clientPlatform)

handshakeResponse.HttpsRequestRegexes = psinetDatabase.GetHttpsRequestRegexes(
"", "", "") // TODO: sponsorID, clientRegion, clientPlatform)
sponsorID)

handshakeResponse.EncodedServerList = psinetDatabase.DiscoverServers(
"", 0) // TODO: propagationChannelID, discoveryValue)
propagationChannelID, geoIPData.DiscoveryValue)

handshakeResponse.ClientRegion = geoIPData.Country
handshakeResponse.ClientRegion = clientRegion

handshakeResponse.ServerTimestamp = psiphon.GetCurrentTimestamp()

Expand Down
6 changes: 3 additions & 3 deletions psiphon/server/psinet.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ func (psinet *PsinetDatabase) GetHomepages(sponsorID, clientRegion, clientPlatfo
// GetUpgradeClientVersion returns a new client version when an upgrade is
// indicated for the specified client current version. The result is "" when
// no upgrade is available.
func (psinet *PsinetDatabase) GetUpgradeClientVersion(clientVersion string) string {
func (psinet *PsinetDatabase) GetUpgradeClientVersion(clientVersion, clientPlatform string) string {

// TODO: implement

return ""
}

// GetHttpsRequestRegexes returns bytes transferred stats regexes for the
// specified client inputs.
func (psinet *PsinetDatabase) GetHttpsRequestRegexes(sponsorID, clientRegion, clientPlatform string) []map[string]string {
// specified sponsor.
func (psinet *PsinetDatabase) GetHttpsRequestRegexes(sponsorID string) []map[string]string {

return make([]map[string]string, 0)
}
Expand Down

0 comments on commit 6ce4c8f

Please sign in to comment.