Skip to content

Commit be1f050

Browse files
committed
fix redirect on non linux OS
1 parent 0de7b8f commit be1f050

File tree

3 files changed

+58
-36
lines changed

3 files changed

+58
-36
lines changed

redirect.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// +build !windows
1+
// +build linux
22

33
package gost
44

redirect_other.go

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// +build !linux
2+
3+
package gost
4+
5+
import (
6+
"errors"
7+
"net"
8+
9+
"github.com/go-log/log"
10+
)
11+
12+
type tcpRedirectHandler struct {
13+
options *HandlerOptions
14+
}
15+
16+
// TCPRedirectHandler creates a server Handler for TCP redirect server.
17+
func TCPRedirectHandler(opts ...HandlerOption) Handler {
18+
h := &tcpRedirectHandler{
19+
options: &HandlerOptions{
20+
Chain: new(Chain),
21+
},
22+
}
23+
for _, opt := range opts {
24+
opt(h.options)
25+
}
26+
return h
27+
}
28+
29+
func (h *tcpRedirectHandler) Init(options ...HandlerOption) {
30+
log.Log("[red-tcp] TCP redirect is not available on the Windows platform")
31+
}
32+
33+
func (h *tcpRedirectHandler) Handle(c net.Conn) {
34+
log.Log("[red-tcp] TCP redirect is not available on the Windows platform")
35+
c.Close()
36+
}
37+
38+
type udpRedirectHandler struct {
39+
}
40+
41+
// UDPRedirectHandler creates a server Handler for UDP transparent server.
42+
func UDPRedirectHandler(opts ...HandlerOption) Handler {
43+
return &udpRedirectHandler{}
44+
}
45+
46+
func (h *udpRedirectHandler) Init(options ...HandlerOption) {
47+
}
48+
49+
func (h *udpRedirectHandler) Handle(conn net.Conn) {
50+
log.Log("[red-udp] UDP redirect is not available on the Windows platform")
51+
conn.Close()
52+
}
53+
54+
// UDPRedirectListener creates a Listener for UDP transparent proxy server.
55+
func UDPRedirectListener(addr string, cfg *UDPListenConfig) (Listener, error) {
56+
return nil, errors.New("UDP redirect is not available on the Windows platform")
57+
}

redirect_win.go

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)