Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F136017
endpoint.go
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
endpoint.go
View Options
package
sshtunnel
import
(
"strings"
"net"
"golang.org/x/crypto/ssh"
"fmt"
"strconv"
"encoding/base64"
)
type
Client
struct
{
}
type
Endpoint
struct
{
Host
string
Port
int
}
func
KeyPrint
(
dialAddr
string
,
addr
net
.
Addr
,
key
ssh
.
PublicKey
)
error
{
fmt
.
Printf
(
"%s %s %s\n"
,
strings
.
Split
(
dialAddr
,
":"
)[
0
],
key
.
Type
(),
base64
.
StdEncoding
.
EncodeToString
(
key
.
Marshal
()))
return
nil
}
func
(
endpoint
*
Endpoint
)
String
()
string
{
return
fmt
.
Sprintf
(
"%s:%d"
,
endpoint
.
Host
,
endpoint
.
Port
)
}
func
ParseEndpointString
(
endpointString
string
)
(
localEp
Endpoint
,
remoteEp
Endpoint
){
localEp
.
Host
=
"localhost"
buffer
:=
strings
.
Split
(
endpointString
,
":"
)
localEp
.
Port
,
_
=
strconv
.
Atoi
(
buffer
[
0
])
remoteEp
.
Host
=
buffer
[
1
]
remoteEp
.
Port
,
_
=
strconv
.
Atoi
(
buffer
[
2
])
return
localEp
,
remoteEp
}
func
ParseEndpointsFromArray
(
endpointStruct
[]
string
)
([]
Endpoint
,
[]
Endpoint
)
{
localEndpoints
:=
make
([]
Endpoint
,
0
)
remoteEndpoints
:=
make
([]
Endpoint
,
0
)
for
_
,
e
:=
range
endpointStruct
{
localE
,
remoteE
:=
ParseEndpointString
(
e
)
localEndpoints
=
append
(
localEndpoints
,
localE
)
remoteEndpoints
=
append
(
remoteEndpoints
,
remoteE
)
}
return
localEndpoints
,
remoteEndpoints
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Feb 23, 6:47 PM (4 h, 16 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15142
Default Alt Text
endpoint.go (1 KB)
Attached To
rST sshtunnel
Event Timeline
Log In to Comment