Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Snowflake
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
trinity-1686a
Snowflake
Commits
4623c7d3
Commit
4623c7d3
authored
3 years ago
by
Cecylia Bocovich
Browse files
Options
Downloads
Patches
Plain Diff
Add documentation where necessary for exported items
parent
5339ed2d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
server/lib/http.go
+1
-0
1 addition, 0 deletions
server/lib/http.go
server/lib/snowflake.go
+13
-5
13 additions, 5 deletions
server/lib/snowflake.go
with
14 additions
and
5 deletions
server/lib/http.go
+
1
−
0
View file @
4623c7d3
...
@@ -193,6 +193,7 @@ func turbotunnelMode(conn net.Conn, addr net.Addr, pconn *turbotunnel.QueuePacke
...
@@ -193,6 +193,7 @@ func turbotunnelMode(conn net.Conn, addr net.Addr, pconn *turbotunnel.QueuePacke
return
nil
return
nil
}
}
// ClientMapAddr is a string that represents a connecting client.
type
ClientMapAddr
string
type
ClientMapAddr
string
func
(
addr
ClientMapAddr
)
Network
()
string
{
func
(
addr
ClientMapAddr
)
Network
()
string
{
...
...
This diff is collapsed.
Click to expand it.
server/lib/snowflake.go
+
13
−
5
View file @
4623c7d3
...
@@ -17,7 +17,9 @@ import (
...
@@ -17,7 +17,9 @@ import (
)
)
const
(
const
(
// WindowSize is the number of packets in the send and receive window of a KCP connection.
WindowSize
=
65535
WindowSize
=
65535
// StreamSize controls the maximum amount of in flight data between a client and server.
StreamSize
=
1048576
//1MB
StreamSize
=
1048576
//1MB
)
)
...
@@ -27,11 +29,14 @@ type Transport struct {
...
@@ -27,11 +29,14 @@ type Transport struct {
getCertificate
func
(
*
tls
.
ClientHelloInfo
)
(
*
tls
.
Certificate
,
error
)
getCertificate
func
(
*
tls
.
ClientHelloInfo
)
(
*
tls
.
Certificate
,
error
)
}
}
// NewSnowflakeServer returns a new server-side Transport for Snowflake.
func
NewSnowflakeServer
(
getCertificate
func
(
*
tls
.
ClientHelloInfo
)
(
*
tls
.
Certificate
,
error
))
*
Transport
{
func
NewSnowflakeServer
(
getCertificate
func
(
*
tls
.
ClientHelloInfo
)
(
*
tls
.
Certificate
,
error
))
*
Transport
{
return
&
Transport
{
getCertificate
:
getCertificate
}
return
&
Transport
{
getCertificate
:
getCertificate
}
}
}
// Listen starts a listener on addr that will accept both turbotunnel
// and legacy Snowflake connections.
func
(
t
*
Transport
)
Listen
(
addr
net
.
Addr
)
(
*
SnowflakeListener
,
error
)
{
func
(
t
*
Transport
)
Listen
(
addr
net
.
Addr
)
(
*
SnowflakeListener
,
error
)
{
listener
:=
&
SnowflakeListener
{
addr
:
addr
,
queue
:
make
(
chan
net
.
Conn
,
65534
)}
listener
:=
&
SnowflakeListener
{
addr
:
addr
,
queue
:
make
(
chan
net
.
Conn
,
65534
)}
...
@@ -129,9 +134,9 @@ type SnowflakeListener struct {
...
@@ -129,9 +134,9 @@ type SnowflakeListener struct {
closeOnce
sync
.
Once
closeOnce
sync
.
Once
}
}
// Allows the caller to accept incoming Snowflake connections
// A
ccept a
llows the caller to accept incoming Snowflake connections
.
// We accept connections from a queue to accommodate both incoming
// We accept connections from a queue to accommodate both incoming
// smux Streams and legacy non-turbotunnel connections
// smux Streams and legacy non-turbotunnel connections
.
func
(
l
*
SnowflakeListener
)
Accept
()
(
net
.
Conn
,
error
)
{
func
(
l
*
SnowflakeListener
)
Accept
()
(
net
.
Conn
,
error
)
{
select
{
select
{
case
<-
l
.
closed
:
case
<-
l
.
closed
:
...
@@ -142,10 +147,12 @@ func (l *SnowflakeListener) Accept() (net.Conn, error) {
...
@@ -142,10 +147,12 @@ func (l *SnowflakeListener) Accept() (net.Conn, error) {
}
}
}
}
// Addr returns the address of the SnowflakeListener
func
(
l
*
SnowflakeListener
)
Addr
()
net
.
Addr
{
func
(
l
*
SnowflakeListener
)
Addr
()
net
.
Addr
{
return
l
.
addr
return
l
.
addr
}
}
// Close closes the Snowflake connection.
func
(
l
*
SnowflakeListener
)
Close
()
error
{
func
(
l
*
SnowflakeListener
)
Close
()
error
{
// Close our HTTP server and our KCP listener
// Close our HTTP server and our KCP listener
l
.
closeOnce
.
Do
(
func
()
{
l
.
closeOnce
.
Do
(
func
()
{
...
@@ -235,14 +242,15 @@ func (l *SnowflakeListener) queueConn(conn net.Conn) error {
...
@@ -235,14 +242,15 @@ func (l *SnowflakeListener) queueConn(conn net.Conn) error {
}
}
}
}
//
A
wrapper for the underlying oneshot or turbotunnel
conn
//
SnowflakeClientConn is a
wrapper for the underlying oneshot or turbotunnel
//
because w
e need to reference our
mapping
to determine the
client
//
conn. W
e need to reference our
client address map
to determine the
// address
//
remote
address
type
SnowflakeClientConn
struct
{
type
SnowflakeClientConn
struct
{
net
.
Conn
net
.
Conn
address
net
.
Addr
address
net
.
Addr
}
}
// RemoteAddr returns the mapped client address of the Snowflake connection
func
(
conn
*
SnowflakeClientConn
)
RemoteAddr
()
net
.
Addr
{
func
(
conn
*
SnowflakeClientConn
)
RemoteAddr
()
net
.
Addr
{
return
conn
.
address
return
conn
.
address
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment