Skip to content

Commit

Permalink
Working quic server+client:
Browse files Browse the repository at this point in the history
- added mock quic server and client
- fixed bug in quic server + streams (teach quicServer to start new
  go-routine to handle streams)
  • Loading branch information
opencoff committed Jul 3, 2020
1 parent 54394f5 commit 1e2c348
Show file tree
Hide file tree
Showing 9 changed files with 719 additions and 42 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/opencoff/go-tunnel
go 1.14

require (
github.com/lucas-clemente/quic-go v0.17.1
github.com/opencoff/go-logger v0.2.0
github.com/lucas-clemente/quic-go v0.17.2
github.com/opencoff/go-logger v0.2.2
github.com/opencoff/go-ratelimit v0.7.0
github.com/opencoff/pflag v0.5.0
gopkg.in/yaml.v2 v2.3.0
Expand Down
10 changes: 6 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/lucas-clemente/quic-go v0.17.1 h1:ezsH76xpn6hKugfsXUy6voIJBFmAOwnM/Oy9F4b/n+M=
github.com/lucas-clemente/quic-go v0.17.1/go.mod h1:I0+fcNTdb9eS1ZcjQZbDVPGchJ86chcIxPALn9lEJqE=
github.com/lucas-clemente/quic-go v0.17.2 h1:4iQInIuNQkPNZmsy9rCnwuOzpH0qGnDo4jn0QfI/qE4=
github.com/lucas-clemente/quic-go v0.17.2/go.mod h1:I0+fcNTdb9eS1ZcjQZbDVPGchJ86chcIxPALn9lEJqE=
github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI=
github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/marten-seemann/qpack v0.1.0/go.mod h1:LFt1NU/Ptjip0C2CPkhimBz5CGE3WGDAUWqna+CNTrI=
Expand All @@ -80,8 +80,10 @@ github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W
github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.8.1/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA=
github.com/opencoff/go-logger v0.2.0 h1:8YvwfTljg0/kR87m8sEL0QFJczT694i30XiqGyaQjWk=
github.com/opencoff/go-logger v0.2.0/go.mod h1:0uZokzKt+uCJkbz12vSoChasSJoLc2aNuCS0A/U7Dqs=
github.com/opencoff/go-logger v0.2.1 h1:xQNQDLLSGh8gOTNVzc3hksRhQVyWCjSyOO27ruzlF9I=
github.com/opencoff/go-logger v0.2.1/go.mod h1:0uZokzKt+uCJkbz12vSoChasSJoLc2aNuCS0A/U7Dqs=
github.com/opencoff/go-logger v0.2.2 h1:xxQFaYbyXEYd4YL5QraKu2YUc1iEv5ACvx8L3uUxY4s=
github.com/opencoff/go-logger v0.2.2/go.mod h1:0uZokzKt+uCJkbz12vSoChasSJoLc2aNuCS0A/U7Dqs=
github.com/opencoff/go-ratelimit v0.7.0 h1:hXadrYOPFlS6l+jmrok87BX0Oh+oeWuLelNYXAUgGqA=
github.com/opencoff/go-ratelimit v0.7.0/go.mod h1:CZOjkRlhRo07XJt81kMF0NfOP7cYTfhZG1zPU5AAK78=
github.com/opencoff/golang-lru v0.6.0 h1:e5jyAHA4AJbohh8mmPB6JpTvZMVrnh3z5GFAqTADVm8=
Expand Down
38 changes: 25 additions & 13 deletions gotun/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package main

import (
"bytes"
"crypto/tls"
"crypto/x509"
"fmt"
Expand Down Expand Up @@ -432,38 +433,49 @@ func (c *Conf) Path(nm string) string {

// Print config in human readable format
func (c *Conf) Dump(w io.Writer) {
fmt.Fprintf(w, "config: %d listeners\n", len(c.Listen))

b := &bytes.Buffer{}

fmt.Fprintf(b, "config: %d listeners\n", len(c.Listen))

for _, l := range c.Listen {
fmt.Fprintf(w, "listen on %s", l.Addr)
fmt.Fprintf(b, "listen on %s", l.Addr)
if l.Quic {
fmt.Fprintf(b, " quic")
}
if t := l.Tls; t != nil {
if len(t.Sni) > 0 {
fmt.Fprintf(w, " with tls sni using certstore %s", t.Sni)
fmt.Fprintf(b, " bith tls sni using certstore %s", t.Sni)
} else {
fmt.Fprintf(w, " with tls using cert %s, key %s",
fmt.Fprintf(b, " bith tls using cert %s, key %s",
t.Cert, t.Key)
}
if t.ClientCert == "required" {
fmt.Fprintf(w, " requiring client auth")
fmt.Fprintf(b, " requiring client auth")
} else if t.ClientCert == "optional" {
fmt.Fprintf(w, " with optional client auth")
fmt.Fprintf(b, " bith optional client auth")
}
}
c := &l.Connect
fmt.Fprintf(w, "\n\tconnect to %s", c.Addr)
fmt.Fprintf(b, "\n\tconnect to %s", c.Addr)
if len(c.Bind) > 0 {
fmt.Fprintf(w, " from %s", c.Bind)
fmt.Fprintf(b, " from %s", c.Bind)
}
if len(c.ProxyProtocol) > 0 {
fmt.Fprintf(w, " using proxy-protocol %s", c.ProxyProtocol)
fmt.Fprintf(b, " using proxy-protocol %s", c.ProxyProtocol)
}
if c.Quic {
fmt.Fprintf(b, " with quic")
}
if t := c.Tls; t != nil {
fmt.Fprintf(w, " using tls")
fmt.Fprintf(b, " using tls")
if len(t.Cert) > 0 {
fmt.Fprintf(w, " cert %s, key %s", t.Cert, t.Key)
fmt.Fprintf(b, " cert %s, key %s", t.Cert, t.Key)
}
fmt.Fprintf(w, " and ca-bundle %s", t.Ca)
fmt.Fprintf(b, " and ca-bundle %s", t.Ca)
}
fmt.Fprintf(w, "\n")
fmt.Fprintf(b, "\n")
}

w.Write(b.Bytes())
}
Loading

0 comments on commit 1e2c348

Please sign in to comment.