migrate to go module; ignore more irrelevant code at the wasm side

This commit is contained in:
Thilo Karraß 2023-02-20 11:55:50 +01:00
parent f937a7ae3e
commit d772b82e94
8 changed files with 60 additions and 34 deletions

View File

@ -1,4 +1,4 @@
package zocket /* import "udico.de/dreem/zocket" */
package zocket
// Addr represents a (the) WebSocket end point address.
// Since WebSocket connections are upgraded HTTP Connections,

View File

@ -1,6 +1,6 @@
// +build js, wasm
//go:build js && wasm
package zocket /* import "udico.de/dreem/zocket" */
package zocket
import (
"context"
@ -80,7 +80,6 @@ func Dial(ctx context.Context, target string) (net.Conn, error) {
return ret, nil
}
// Read gets some bytes from a ws frame. Blocks.
func (c ClientConnection) Read(b []byte) (int, error) {
fmt.Println("client_read")
@ -138,7 +137,7 @@ func (c ClientConnection) Close() error {
// dummy and make underlying layers think they're using a tcp conection.
func (c ClientConnection) LocalAddr() net.Addr {
fmt.Println("DBG: call LocalAddr() on ClientConnection")
return Addr {
return Addr{
network: "tcp",
address: "0.0.0.0",
}
@ -147,7 +146,7 @@ func (c ClientConnection) LocalAddr() net.Addr {
// RemoteAddr returns the adress of the remote endpoint.
func (c ClientConnection) RemoteAddr() net.Addr {
fmt.Println("DBG: call RemoteAddr() on ClientConnection")
return Addr {
return Addr{
network: "tcp",
// TODO: Use the real servers adress somehow (or none at all? :think:)
address: "127.0.0.1",

5
doc.go
View File

@ -1,3 +1,2 @@
// Zocket transparently tunnels a TCP connection through a WebSocket layer from within WebAssembly.
package zocket /* import "udico.de/dreem/zocket" */
// Package zocket transparently tunnels a TCP connection through a WebSocket layer from within WebAssembly.
package zocket

View File

@ -1,4 +1,6 @@
package zocket /* import "udico.de/dreem/zocket" */
//go:build !js && !wasm
package zocket
import (
"encoding/binary"
@ -19,7 +21,7 @@ const (
)
/*
*
* Frame
*/
type Frame struct {
Fin bool

7
go.mod Normal file
View File

@ -0,0 +1,7 @@
module udico.de/dreem/zocket
go 1.20
require github.com/sirupsen/logrus v1.9.0
require golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect

15
go.sum Normal file
View File

@ -0,0 +1,15 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View File

@ -1,4 +1,6 @@
package zocket /* import "udico.de/dreem/zocket" */
//go:build !js || !wasm
package zocket
import (
"bufio"

View File

@ -1,4 +1,6 @@
package zocket /* import "udico.de/dreem/zocket" */
//go:build !js || !wasm
package zocket
import (
"bytes"
@ -30,8 +32,8 @@ func (c ServerConnection) Read(b []byte) (int, error) {
}
return len(b), nil
}
buf := &bytes.Buffer{}//
datloop:
buf := &bytes.Buffer{} //
datloop:
for {
tFrame, err := ReadFrame(c.conn)
if err != nil {