Fix missing bypass and update README
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
089bc9c6e4
commit
eefbd63e5a
10
README.md
10
README.md
|
@ -9,11 +9,17 @@ A simple TCP proxy. Currently used in [AppVenture](https://appventure.nushigh.ed
|
||||||
$ ./forward -help
|
$ ./forward -help
|
||||||
Usage of ./forward:
|
Usage of ./forward:
|
||||||
-connect string
|
-connect string
|
||||||
forward to ip and port (default ":8080")
|
forward to address
|
||||||
-listen string
|
-listen string
|
||||||
listen on ip and port (default ":8081")
|
listen on address (default ":8000")
|
||||||
|
-ssh string
|
||||||
|
if set, will do basic introspection to forward SSH traffic to this address
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Usage with SSH
|
||||||
|
|
||||||
|
You can use `forward` to do multiplexing of SSH and HTTP in a quick and dirty way, using very simple protocol introspection. A more robust solution would be [sshttp](https://github.com/stealth/sshttp)
|
||||||
|
|
||||||
## Usage on Windows
|
## Usage on Windows
|
||||||
|
|
||||||
`forward` is wrapped with [go-svc](https://github.com/judwhite/go-svc), enabling it to be run as a Windows service. To add with PowerShell:
|
`forward` is wrapped with [go-svc](https://github.com/judwhite/go-svc), enabling it to be run as a Windows service. To add with PowerShell:
|
||||||
|
|
74
server.go
74
server.go
|
@ -70,37 +70,53 @@ var magic = []byte{'S', 'S', 'H', '-'}
|
||||||
var magicLen = len(magic)
|
var magicLen = len(magic)
|
||||||
|
|
||||||
func handle(c net.Conn, count int) {
|
func handle(c net.Conn, count int) {
|
||||||
// read first four characters
|
if connSSH != nil {
|
||||||
readMagic := make([]byte, magicLen, magicLen)
|
|
||||||
n, err := c.Read(readMagic)
|
// read first four characters
|
||||||
if n != magicLen {
|
readMagic := make([]byte, magicLen, magicLen)
|
||||||
log.Printf("warning! could not read header")
|
n, err := c.Read(readMagic)
|
||||||
return
|
if n != magicLen {
|
||||||
}
|
log.Printf("warning! could not read header")
|
||||||
opError, ok := err.(*net.OpError)
|
return
|
||||||
if err != nil && (!ok || opError.Op != "readfrom") {
|
}
|
||||||
log.Printf("warning! %v", err)
|
opError, ok := err.(*net.OpError)
|
||||||
return
|
if err != nil && (!ok || opError.Op != "readfrom") {
|
||||||
}
|
log.Printf("warning! %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
connTo := conn
|
||||||
|
// if the header looks like SSH, forward to SSH connection
|
||||||
|
if bytes.Equal(readMagic, magic) {
|
||||||
|
connTo = connSSH
|
||||||
|
}
|
||||||
|
|
||||||
|
cn, err := net.DialTCP("tcp", nil, connTo)
|
||||||
|
if err != nil {
|
||||||
|
c.Close()
|
||||||
|
log.Print(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// write the first four characters
|
||||||
|
cn.Write(readMagic)
|
||||||
|
|
||||||
|
go pipe(c, cn, count)
|
||||||
|
go pipe(cn, c, count)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
cn, err := net.DialTCP("tcp", nil, conn)
|
||||||
|
if err != nil {
|
||||||
|
c.Close()
|
||||||
|
log.Print(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
go pipe(c, cn, count)
|
||||||
|
go pipe(cn, c, count)
|
||||||
|
|
||||||
connTo := conn
|
|
||||||
// if the header looks like SSH, forward to SSH connection
|
|
||||||
if bytes.Equal(readMagic, magic) {
|
|
||||||
connTo = connSSH
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cn, err := net.DialTCP("tcp", nil, connTo)
|
|
||||||
if err != nil {
|
|
||||||
c.Close()
|
|
||||||
log.Print(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// write the first four characters
|
|
||||||
cn.Write(readMagic)
|
|
||||||
|
|
||||||
go pipe(c, cn, count)
|
|
||||||
go pipe(cn, c, count)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func pipe(w io.WriteCloser, r io.ReadCloser, count int) {
|
func pipe(w io.WriteCloser, r io.ReadCloser, count int) {
|
||||||
|
|
Loading…
Reference in New Issue