Skip to content

Commit

Permalink
add pac support and ready to add config file
Browse files Browse the repository at this point in the history
  • Loading branch information
asche910 committed Oct 17, 2019
1 parent c4c74af commit 0eceb86
Show file tree
Hide file tree
Showing 9 changed files with 5,657 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func printHelp() {
'rc4-md5-6', 'chacha20', 'chacha20-ietf'], default is 'aes-256-cfb'
-P, --password password of server
-V, --verbose output detail info
-l, --logs output detail info to logs file
-l, --log output detail info to log file
-H, --help show detail usage
Mail bug reports and suggestions to <asche910@gmail.com>
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func printHelp() {
'rc4-md5-6', 'chacha20', 'chacha20-ietf'], default is 'aes-256-cfb'
-P, --password password for client connecting
-V, --verbose output detail info
-l, --logs output detail info to logs file
-l, --log output detail info to log file
-H, --help show detail usage
Mail bug reports and suggestions to <asche910@gmail.com>
Expand Down
26 changes: 26 additions & 0 deletions fly/pac.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
package fly

import (
"fmt"
"io"
"net/http"
"os"
)

func StartPAC() {
http.HandleFunc("/flynet.pac", func (w http.ResponseWriter, r *http.Request){
// the pac file should be placed at the same dir with current running file.
// but it is placed at the parent dir when development
file, err := os.Open(`flynet.pac`)
if err != nil {
fmt.Println(err)
// run from cmd/client/
file, _ = os.Open("../../flynet.pac")
}
w.Header().Set("Content-Type", "application/x-ns-proxy-autoconfig")
io.Copy(w, file)
w.WriteHeader(200)

})
err := http.ListenAndServe(":8080", nil)
if err != nil {
fmt.Println("start failed --->", err)
}
}
7 changes: 7 additions & 0 deletions fly/pac_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package fly

import "testing"

func TestStartPAC(t *testing.T) {
StartPAC()
}
5 changes: 4 additions & 1 deletion fly/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package fly
import (
"fmt"
"github.com/xtaci/kcp-go"
"io"
"net"
)

Expand Down Expand Up @@ -45,7 +46,9 @@ func RelayTraffic(dst, src net.Conn) {
for {
n, err := src.Read(buff)
if err != nil {
fmt.Println(err)
if err != io.EOF {
fmt.Println(err)
}
break
}
//logger.Println("Read", n)
Expand Down
2 changes: 1 addition & 1 deletion fly/socks5.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func Socks5ForServerByTCP(localPort, method, key string) {

host, port := parseSocksRequest(buff[:n], n)
//logger.Printf("target server ------\n%s:%s\n------\n%d\n+++++++\n", host, port, buff[:n])
logger.Printf("target server ------\n%s:%s\n------\n", host, port)
logger.Printf("target server ---> %s:%s <---\n", host, port)

// dial the target server
server, err := net.Dial("tcp", net.JoinHostPort(host, port))
Expand Down
22 changes: 22 additions & 0 deletions flynet.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# flynet config file
#
# multiple line you can use ``
#

[server]
mode = socks-tcp
port = 8888 # listen port for client to connect
method = "aes-256-cfb"
password =
# verbose = true
# log = flynet.log


[client]
mode = socks-tcp
port = 1080 # local socks5 listen port
serverAddr = example.com:8080 # include host and port
method = "aes-256-cfb"
password =
# verbose = true
# log = flynet.log
Loading

0 comments on commit 0eceb86

Please sign in to comment.