Use commandline options
parent
a019fa6da5
commit
64b8ee7aaa
|
@ -1,17 +1,23 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"github.com/serverwentdown/bypass"
|
||||
)
|
||||
|
||||
var listen string
|
||||
|
||||
func main() {
|
||||
flag.StringVar(&listen, "listen", ":8000", "listen on ip and port")
|
||||
flag.Parse()
|
||||
|
||||
conf := &socks5.Config{}
|
||||
server, err := socks5.New(conf)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if err := server.ListenAndServe("tcp", "127.0.0.1:8000"); err != nil {
|
||||
if err := server.ListenAndServe("tcp", listen); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
|
13
request.go
13
request.go
|
@ -1,13 +1,14 @@
|
|||
package socks5
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"math/big"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
"math/big"
|
||||
"bytes"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
@ -372,8 +373,8 @@ func copyAndModify(dst io.Writer, src io.Reader) (written int64, err error) {
|
|||
for {
|
||||
nr, er := src.Read(buf)
|
||||
if written == 0 && nr > 0 {
|
||||
if (buf[0] == 0x16 && buf[5] == 0x01) {// && buf[1] == 0x03 && buf[2] == 0x01) {
|
||||
modifyHello(buf);
|
||||
if buf[0] == 0x16 && buf[5] == 0x01 { // && buf[1] == 0x03 && buf[2] == 0x01) {
|
||||
modifyHello(buf)
|
||||
}
|
||||
}
|
||||
if nr > 0 {
|
||||
|
@ -446,7 +447,7 @@ func modifyHello(buf []byte) {
|
|||
extensionsEnd := extensionsStart + extensionsLength.Uint64()
|
||||
cur := extensionsStart
|
||||
for cur+4 < extensionsEnd {
|
||||
if (buf[cur] != 0x00 || buf[cur + 1] != 0x00) {
|
||||
if buf[cur] != 0x00 || buf[cur+1] != 0x00 {
|
||||
extensionLength := big.NewInt(0)
|
||||
extensionLength.SetBytes(buf[cur+2 : cur+4])
|
||||
cur += 4 + extensionLength.Uint64()
|
||||
|
@ -480,7 +481,7 @@ func modifyHello(buf []byte) {
|
|||
list = append(list, name.String())
|
||||
lcur += 3 + nameLength.Uint64()
|
||||
}
|
||||
fmt.Println(list)
|
||||
log.Println(list)
|
||||
|
||||
break
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue