Skip to content

Commit

Permalink
more debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
bigeagle committed Dec 1, 2013
1 parent a5940b2 commit bddc4ac
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ So I'm going to implement a VPN with these features:

1. Pre-shared key based authentication, randomly generated key for encryption. NO SSL, maybe a reinvented SSL :).
2. "Frequency hopping"-like port and protocol hopping, both handshake and packet transmission will be acctually done in random port and protocol.
3. Flow obfuscation to hide HTTP characters.
3. Traffic shaping to hide protocol's statistical properties.

Implemention
-------
Expand All @@ -37,13 +37,12 @@ You can get updated release from https://github.com/bigeagle/gohop/releases , go

### Build and Install

There's no prebuilt binary relase yet, u need to compile it yourself. Go 1.1 enviroment is needed, google is your friend.

First get dependency libraries and gohop source code.

```
go get github.com/bigeagle/go-logging
go get github.com/bigeagle/water
go get code.google.com/p/gcfg
go get github.com/bigeagle/gohop
```

Expand All @@ -55,21 +54,21 @@ go install github.com/bigeagle/gohop

### Config and Run

on the server, if u are using it for anti-GFW internet access, ip forwarding is needed:
On the server, if u are using it for anti-GFW internet access, ip forwarding is needed:

```
sysctl net.ipv4.ip_forward=1
iptables -t nat -A POSTROUTING -j MASQUERADE
```

edit `server.json` as your server's config file, **currently u need to set ip address manually**. Run
edit `server.ini` as your server's config file. Run
```
gohop -server server.json
gohop server.ini
```

at client side, edit `client.json` as your config file, custom routes is supported so that in-china network packets will not go through gohop. And again, **u need to set ip address manually**. Run
at client side, edit `client.ini` as your config file, custom routes is supported so that in-china network packets will not go through gohop. Run
```
gohop -client client.json
gohop client.ini
```
wait until u see `Connection Initialized`, pay attention to your DNS config, if u are using a Chinese DNS server, u're still unable to access blocked websites.

Expand Down
6 changes: 4 additions & 2 deletions hop/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ type HopClient struct {
func NewClient(cfg HopClientConfig) error {
var err error

logger.Debug("%v", cfg)
// logger.Debug("%v", cfg)
cipher, err = newHopCipher([]byte(cfg.Key))
if err != nil {
return err
Expand Down Expand Up @@ -253,15 +253,17 @@ func (clt *HopClient) handleUDP(server string) {

buf := make([]byte, IFACE_BUFSIZE)
for {
logger.Debug("waiting for udp packet")
n, err := udpConn.Read(buf)
// logger.Debug("New UDP Packet, len: %d", n)
logger.Debug("New UDP Packet, len: %d", n)
if err != nil {
logger.Error(err.Error())
return
}

hp, err := unpackHopPacket(buf[:n])
if err != nil {
logger.Debug("Error depacketing")
continue
}
if handle_func, ok := pktHandle[hp.Flag]; ok {
Expand Down
1 change: 1 addition & 0 deletions hop/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ func serverParseConfig(cfgFile string) (*hopServerConfig, error) {
type HopServerConfig struct {
HopStart int
HopEnd int
ListenAddr string
Addr string
MTU int
Key string
Expand Down
12 changes: 7 additions & 5 deletions hop/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func NewServer(cfg HopServerConfig) error {

// serve for multiple ports
for idx, port := 0, cfg.HopStart; port <= cfg.HopEnd; port++ {
go hopServer.listenAndServe(fmt.Sprintf("%d", port), idx)
go hopServer.listenAndServe(cfg.ListenAddr, fmt.Sprintf("%d", port), idx)
idx++
}

Expand Down Expand Up @@ -158,8 +158,8 @@ func NewServer(cfg HopServerConfig) error {

}

func (srv *HopServer) listenAndServe(port string, idx int) {
port = ":" + port
func (srv *HopServer) listenAndServe(addr string, port string, idx int) {
port = addr + ":" + port
udpAddr, err := net.ResolveUDPAddr("udp", port)
if err != nil {
logger.Error("Invalid port: %s", port)
Expand Down Expand Up @@ -262,10 +262,12 @@ func (srv *HopServer) toClient(peer *HopPeer, flag byte, payload []byte, noise b
hp.Flag = flag
hp.payload = payload

// logger.Debug("Peer: %v", hpeer)
if addr, idx, ok := peer.addr(); ok {
logger.Debug("peer: %v", addr)
upacket := &udpPacket{addr, hp.Pack(), idx}
srv.toNet[idx] <- upacket
} else {
logger.Debug("peer not found")
}
}

Expand Down Expand Up @@ -297,7 +299,7 @@ func (srv *HopServer) bufferToClient(peer *HopPeer, buf []byte) {

func (srv *HopServer) handleKnock(u *udpPacket, hp *HopPacket) {
sid := uint64(binary.BigEndian.Uint32(hp.payload[:4]))
// logger.Debug("port knock from client %v, sid: %d", u.addr, sid)
logger.Debug("port knock from client %v, sid: %d", u.addr, sid)
sid = (sid << 32) & uint64(0xFFFFFFFF00000000)

hpeer, ok := srv.peers[sid]
Expand Down

0 comments on commit bddc4ac

Please sign in to comment.