Browse Source

Merge pull request #9 from rod-hynes/master

Missing new source file; Emit version number
Rod Hynes 11 years ago
parent
commit
1abcaf38a1
3 changed files with 48 additions and 0 deletions
  1. 1 0
      psiphon/defaults.go
  2. 46 0
      psiphon/notice.go
  3. 1 0
      psiphon/runTunnel.go

+ 1 - 0
psiphon/defaults.go

@@ -24,6 +24,7 @@ import (
 )
 
 const (
+	VERSION                                  = "0.1"
 	DATA_STORE_FILENAME                      = "psiphon.db"
 	FETCH_REMOTE_SERVER_LIST_TIMEOUT         = 5 * time.Second
 	TUNNEL_CONNECT_TIMEOUT                   = 15 * time.Second

+ 46 - 0
psiphon/notice.go

@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2014, Psiphon Inc.
+ * All rights reserved.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package psiphon
+
+import (
+	"fmt"
+	"log"
+)
+
+const (
+	NOTICE_INFO            = "INFO"
+	NOTICE_ALERT           = "ALERT"
+	NOTICE_VERSION         = "VERSION"
+	NOTICE_TUNNEL          = "TUNNEL"
+	NOTICE_SOCKS_PROXY     = "SOCKS-PROXY"
+	NOTICE_HTTP_PROXY      = "HTTP-PROXY"
+	NOTICE_UPGRADE         = "UPGRADE"
+	NOTICE_HOMEPAGE        = "HOMEPAGE"
+	NOTICE_PAGE_VIEW_REGEX = "PAGE-VIEW-REGEX"
+	NOTICE_HTTPS_REGEX     = "HTTPS-REGEX"
+)
+
+func Notice(prefix, format string, args ...interface{}) {
+	log.Printf("%s %s", prefix, fmt.Sprintf(format, args...))
+}
+
+func Fatal(format string, args ...interface{}) {
+	log.Printf("FATAL %s", fmt.Sprintf(format, args...))
+}

+ 1 - 0
psiphon/runTunnel.go

@@ -194,6 +194,7 @@ func RunTunnelForever(config *Config) {
 		// TODO
 		//log.SetOutput(ioutil.Discard)
 	}
+	Notice(NOTICE_VERSION, VERSION)
 	// TODO: unlike existing Psiphon clients, this code
 	// always makes the fetch remote server list request
 	go func() {