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

Added config parameters for local proxy listening ports

Rod Hynes 11 лет назад
Родитель
Сommit
cd2d405d75
4 измененных файлов с 10 добавлено и 6 удалено
  1. 2 0
      psiphon/config.go
  2. 3 2
      psiphon/httpProxy.go
  3. 2 2
      psiphon/runTunnel.go
  4. 3 2
      psiphon/socksProxy.go

+ 2 - 0
psiphon/config.go

@@ -35,6 +35,8 @@ type Config struct {
 	ClientPlatform                     string
 	TunnelWholeDevice                  int
 	EgressRegion                       string
+	LocalSocksProxyPort                int
+	LocalHttpProxyPort                 int
 }
 
 // LoadConfig reads, and parse, and validates a JSON format Psiphon config

+ 3 - 2
psiphon/httpProxy.go

@@ -21,6 +21,7 @@ package psiphon
 
 import (
 	"errors"
+	"fmt"
 	"io"
 	"net"
 	"net/http"
@@ -38,8 +39,8 @@ type HttpProxy struct {
 }
 
 // NewHttpProxy initializes and runs a new HTTP proxy server.
-func NewHttpProxy(tunnel *Tunnel, failureSignal chan bool) (proxy *HttpProxy, err error) {
-	listener, err := net.Listen("tcp", "127.0.0.1:0")
+func NewHttpProxy(listenPort int, tunnel *Tunnel, failureSignal chan bool) (proxy *HttpProxy, err error) {
+	listener, err := net.Listen("tcp", fmt.Sprintf("127.0.0.1:%d", listenPort))
 	if err != nil {
 		return nil, err
 	}

+ 2 - 2
psiphon/runTunnel.go

@@ -155,12 +155,12 @@ func runTunnel(config *Config) error {
 	if err != nil {
 		return fmt.Errorf("failed to set closed signal: %s", err)
 	}
-	socksProxy, err := NewSocksProxy(tunnel, stopTunnelSignal)
+	socksProxy, err := NewSocksProxy(config.LocalSocksProxyPort, tunnel, stopTunnelSignal)
 	if err != nil {
 		return fmt.Errorf("error initializing local SOCKS proxy: %s", err)
 	}
 	defer socksProxy.Close()
-	httpProxy, err := NewHttpProxy(tunnel, stopTunnelSignal)
+	httpProxy, err := NewHttpProxy(config.LocalHttpProxyPort, tunnel, stopTunnelSignal)
 	if err != nil {
 		return fmt.Errorf("error initializing local HTTP proxy: %s", err)
 	}

+ 3 - 2
psiphon/socksProxy.go

@@ -20,6 +20,7 @@
 package psiphon
 
 import (
+	"fmt"
 	socks "git.torproject.org/pluggable-transports/goptlib.git"
 	"io"
 	"net"
@@ -40,8 +41,8 @@ type SocksProxy struct {
 // NewSocksProxy initializes a new SOCKS server. It begins listening for
 // connections, starts a goroutine that runs an accept loop, and returns
 // leaving the accept loop running.
-func NewSocksProxy(tunnel *Tunnel, failureSignal chan bool) (proxy *SocksProxy, err error) {
-	listener, err := socks.ListenSocks("tcp", "127.0.0.1:0")
+func NewSocksProxy(listenPort int, tunnel *Tunnel, failureSignal chan bool) (proxy *SocksProxy, err error) {
+	listener, err := socks.ListenSocks("tcp", fmt.Sprintf("127.0.0.1:%d", listenPort))
 	if err != nil {
 		return nil, err
 	}