Просмотр исходного кода

Emit VPN PSK when returned in handshake

Rod Hynes 11 лет назад
Родитель
Сommit
ac57493bef
2 измененных файлов с 11 добавлено и 1 удалено
  1. 2 1
      psiphon/notice.go
  2. 9 0
      psiphon/serverApi.go

+ 2 - 1
psiphon/notice.go

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Psiphon Inc.
+ * Copyright (c) 2015, Psiphon Inc.
  * All rights reserved.
  *
  * This program is free software: you can redistribute it and/or modify
@@ -35,6 +35,7 @@ const (
 	NOTICE_HOMEPAGE         = "HOMEPAGE"
 	NOTICE_PAGE_VIEW_REGEX  = "PAGE-VIEW-REGEX"
 	NOTICE_HTTPS_REGEX      = "HTTPS-REGEX"
+	NOTICE_VPN_PSK          = "VPN-PSK"
 )
 
 func Notice(prefix, format string, args ...interface{}) {

+ 9 - 0
psiphon/serverApi.go

@@ -156,6 +156,7 @@ func (session *Session) doHandshakeRequest() error {
 	if len(configLine) == 0 {
 		return ContextError(errors.New("no config line found"))
 	}
+
 	// Note:
 	// - 'preemptive_reconnect_lifetime_milliseconds' is currently unused
 	// - 'ssh_session_id' is ignored; client session ID is used instead
@@ -165,11 +166,14 @@ func (session *Session) doHandshakeRequest() error {
 		PageViewRegexes      []map[string]string `json:"page_view_regexes"`
 		HttpsRequestRegexes  []map[string]string `json:"https_request_regexes"`
 		EncodedServerList    []string            `json:"encoded_server_list"`
+		VpnPsk               string              `json:"l2tp_ipsec_psk"`
 	}
 	err = json.Unmarshal(configLine, &handshakeConfig)
 	if err != nil {
 		return ContextError(err)
 	}
+
+	// Store discovered server entries
 	for _, encodedServerEntry := range handshakeConfig.EncodedServerList {
 		serverEntry, err := DecodeServerEntry(encodedServerEntry)
 		if err != nil {
@@ -180,6 +184,7 @@ func (session *Session) doHandshakeRequest() error {
 			return ContextError(err)
 		}
 	}
+
 	// TODO: formally communicate the sponsor and upgrade info to an
 	// outer client via some control interface.
 	for _, homepage := range handshakeConfig.Homepages {
@@ -188,6 +193,10 @@ func (session *Session) doHandshakeRequest() error {
 	if handshakeConfig.UpgradeClientVersion != "" {
 		Notice(NOTICE_UPGRADE, "%s", handshakeConfig.UpgradeClientVersion)
 	}
+	if handshakeConfig.VpnPsk != "" {
+		Notice(NOTICE_VPN_PSK, "%s", handshakeConfig.VpnPsk)
+	}
+
 	session.statsRegexps = MakeRegexps(
 		handshakeConfig.PageViewRegexes,
 		handshakeConfig.HttpsRequestRegexes)