mirror of
https://github.com/fatedier/frp.git
synced 2024-11-27 12:39:09 +08:00
utils/conn: support ipv6, fix #62
This commit is contained in:
parent
b4a577b0d7
commit
5d9300c1e9
6
Makefile
6
Makefile
@ -1,15 +1,13 @@
|
||||
export PATH := $(GOPATH)/bin:$(PATH)
|
||||
export GO15VENDOREXPERIMENT := 1
|
||||
|
||||
all: fmt dep build
|
||||
all: fmt build
|
||||
|
||||
build: frps frpc build_test
|
||||
|
||||
build_test: echo_server http_server
|
||||
|
||||
dep: statik
|
||||
|
||||
statik:
|
||||
assets:
|
||||
go get -d github.com/rakyll/statik
|
||||
@go install github.com/rakyll/statik
|
||||
@rm -rf ./src/assets/statik
|
||||
|
@ -1,5 +1,7 @@
|
||||
# [common] is integral section
|
||||
[common]
|
||||
# A literal address or host name for IPv6 must be enclosed
|
||||
# in square brackets, as in "[::1]:80", "[ipv6-host]:http" or "[ipv6-host%zone]:80"
|
||||
server_addr = 0.0.0.0
|
||||
server_port = 7000
|
||||
# console or real logFile path like ./frpc.log
|
||||
|
@ -1,5 +1,7 @@
|
||||
# [common] is integral section
|
||||
[common]
|
||||
# A literal address or host name for IPv6 must be enclosed
|
||||
# in square brackets, as in "[::1]:80", "[ipv6-host]:http" or "[ipv6-host%zone]:80"
|
||||
bind_addr = 0.0.0.0
|
||||
bind_port = 7000
|
||||
# if you want to support virtual host, you must set the http port for listening (optional)
|
||||
|
@ -32,7 +32,10 @@ type Listener struct {
|
||||
}
|
||||
|
||||
func Listen(bindAddr string, bindPort int64) (l *Listener, err error) {
|
||||
tcpAddr, err := net.ResolveTCPAddr("tcp4", fmt.Sprintf("%s:%d", bindAddr, bindPort))
|
||||
tcpAddr, err := net.ResolveTCPAddr("tcp", fmt.Sprintf("%s:%d", bindAddr, bindPort))
|
||||
if err != nil {
|
||||
return l, err
|
||||
}
|
||||
listener, err := net.ListenTCP("tcp", tcpAddr)
|
||||
if err != nil {
|
||||
return l, err
|
||||
@ -103,7 +106,7 @@ func NewConn(conn net.Conn) (c *Conn) {
|
||||
|
||||
func ConnectServer(host string, port int64) (c *Conn, err error) {
|
||||
c = &Conn{}
|
||||
servertAddr, err := net.ResolveTCPAddr("tcp4", fmt.Sprintf("%s:%d", host, port))
|
||||
servertAddr, err := net.ResolveTCPAddr("tcp", fmt.Sprintf("%s:%d", host, port))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user