Browse Source

Emit client region notice

Rod Hynes 10 years ago
parent
commit
3d3463ae3a
2 changed files with 9 additions and 1 deletions
  1. 6 0
      psiphon/notice.go
  2. 3 1
      psiphon/serverApi.go

+ 6 - 0
psiphon/notice.go

@@ -157,6 +157,12 @@ func NoticeHomepage(url string) {
 	outputNotice("Homepage", false, "url", url)
 }
 
+// NoticeClientRegion is the client's region, as determined by the server and
+// reported to the client in the handshake.
+func NoticeClientRegion(region string) {
+	outputNotice("ClientRegion", false, "region", region)
+}
+
 // NoticeTunnels is how many active tunnels are available. The client should use this to
 // determine connecting/unexpected disconnect state transitions. When count is 0, the core is
 // disconnected; when count > 1, the core is connected.

+ 3 - 1
psiphon/serverApi.go

@@ -26,12 +26,13 @@ import (
 	"encoding/json"
 	"errors"
 	"fmt"
-	"github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/transferstats"
 	"io"
 	"io/ioutil"
 	"net"
 	"net/http"
 	"strconv"
+
+	"github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/transferstats"
 )
 
 // Session is a utility struct which holds all of the data associated
@@ -216,6 +217,7 @@ func (session *Session) doHandshakeRequest() error {
 	}
 
 	session.clientRegion = handshakeConfig.ClientRegion
+	NoticeClientRegion(session.clientRegion)
 
 	var decodedServerEntries []*ServerEntry