Skip to content

Commit cad7201

Browse files
committed
ConnectRemote function added
1 parent f7f2539 commit cad7201

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

postbird.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
)
1010

1111
// Info struct
12-
// PostBird 에서 사용될 내용
12+
// PostBird 에서 사용될 값들
1313
type Info struct {
1414
BindPort uint
1515
BindAddress string
@@ -20,14 +20,15 @@ type Info struct {
2020

2121
const DefaultPort uint = 8787 // Default Bind Port
2222
const DefaultBindAddress string = "127.0.0.1" // Default Bind Address
23-
const DefaultServerAddress string = "127.0.0.1" // Defualt Server Address
23+
const DefaultRemoteAddress string = "127.0.0.1" // Defualt Server Address
2424

2525
const (
2626
ServerMode = 0
2727
ClientMode = 1
2828
)
2929

3030
var info Info
31+
var ServerConnection net.Conn
3132

3233
// funcs map
3334
// 원격에서 호출가능한 함수들을 등록해놓은 map
@@ -69,7 +70,7 @@ func init() {
6970
}
7071

7172
if info.RemoteAddress == "" {
72-
info.RemoteAddress = DefaultBindAddress
73+
info.RemoteAddress = DefaultRemoteAddress
7374
}
7475

7576
if info.RemotePort == 0 {
@@ -137,8 +138,13 @@ func requestHandler(c net.Conn) {
137138
}
138139
}
139140

140-
func Connect() {
141-
141+
func ConnectToRemote() {
142+
client, err := net.Dial("tcp", info.RemoteAddress+":"+string(info.RemotePort))
143+
if err != nil {
144+
fmt.Println(err)
145+
return
146+
}
147+
ServerConnection = client
142148
}
143149

144150
// CallLocalFunc func

0 commit comments

Comments
 (0)