Disable datagram support in the dialer function until it's ready, so I can cut a release tonight.

This commit is contained in:
idk
2022-02-01 21:50:35 -05:00
parent 23c45022b3
commit 964219c25f
6 changed files with 35 additions and 10 deletions

View File

@ -1,6 +1,6 @@
USER_GH=eyedeekay
VERSION=0.32.30
VERSION=0.32.4
packagename=gosam
echo: fmt

View File

@ -25,18 +25,11 @@ func (c *Client) Listen() (net.Listener, error) {
func (c *Client) ListenI2P(dest string) (net.Listener, error) {
var err error
c.destination, err = c.CreateStreamSession(dest)
d := c.destination
if err != nil {
return nil, err
}
fmt.Println("Listening on destination:", c.Base32()+".b32.i2p")
c, err = c.NewClient(c.id)
if err != nil {
return nil, err
}
c.destination = d
if c.debug {
c.SamConn = WrapConn(c.SamConn)
}

View File

@ -13,6 +13,8 @@ import (
"strings"
"sync"
"time"
samkeys "github.com/eyedeekay/goSam/compat"
)
// A Client represents a single Connection to the SAM bridge
@ -60,6 +62,7 @@ type Client struct {
sammax int
}
// SAMsigTypes is a slice of the available signature types
var SAMsigTypes = []string{
"SIGNATURE_TYPE=DSA_SHA1",
"SIGNATURE_TYPE=ECDSA_SHA256_P256",
@ -179,12 +182,22 @@ func NewClientFromOptions(opts ...func(*Client) error) (*Client, error) {
return &c, c.hello()
}
// ID returns a the current ID of the client as a string
func (p *Client) ID() string {
return fmt.Sprintf("%d", p.NewID())
}
// Addr returns the address of the client as a net.Addr
func (p *Client) Addr() net.Addr {
return nil
keys, err := samkeys.DestToKeys(p.Destination())
if err != nil {
return nil
}
return keys.Addr()
}
func (p *Client) LocalAddr() net.Addr {
return p.Addr()
}
//return the combined host:port of the SAM bridge

View File

@ -30,11 +30,14 @@ import (
"time"
)
// Conn Read data from the connection, writes data to te connection
// and logs the data in-between.
type Conn struct {
RWC
conn net.Conn
}
// WrapConn wraps a net.Conn in a Conn.
func WrapConn(c net.Conn) *Conn {
wrap := Conn{
conn: c,
@ -45,23 +48,29 @@ func WrapConn(c net.Conn) *Conn {
return &wrap
}
// LocalAddr returns the local address of the connection.
func (c *Conn) LocalAddr() net.Addr {
return c.conn.LocalAddr()
}
// RemoteAddr returns the remote address of the connection.
func (c *Conn) RemoteAddr() net.Addr {
return c.conn.RemoteAddr()
}
// SetDeadline sets the read and write deadlines associated with the connection
func (c *Conn) SetDeadline(t time.Time) error {
log.Println("WARNING: SetDeadline() not sure this works")
return c.conn.SetDeadline(t)
}
// SetReadDeadline sets the read deadline associated with the connection
func (c *Conn) SetReadDeadline(t time.Time) error {
log.Println("WARNING: SetReadDeadline() not sure this works")
return c.conn.SetReadDeadline(t)
}
// SetWriteDeadline sets the write deadline associated with the connection
func (c *Conn) SetWriteDeadline(t time.Time) error {
log.Println("WARNING: SetWriteDeadline() not sure this works")
return c.conn.SetWriteDeadline(t)

View File

@ -5,6 +5,7 @@ import (
"time"
)
// DatagramConn
type DatagramConn interface {
ReadFrom(p []byte) (n int, addr net.Addr, err error)
Read(b []byte) (n int, err error)
@ -17,3 +18,9 @@ type DatagramConn interface {
SetReadDeadline(t time.Time) error
SetWriteDeadline(t time.Time) error
}
/**
var conn DatagramConn = &Client{}
*/

View File

@ -2,6 +2,7 @@ package goSam
import (
"context"
"fmt"
"log"
"net"
"strings"
@ -52,8 +53,10 @@ func (c *Client) DialContextFree(network, addr string) (net.Conn, error) {
return c.DialStreamingContextFree(addr)
}
// DialDatagramContextFree is a "Dialer" for "Client-Like" Datagram connections.
// It is also not finished. If you need datagram support right now, use sam3.
func (c *Client) DialDatagramContextFree(addr string) (DatagramConn, error) {
return c.SamDGConn, nil
return nil, fmt.Errorf("Datagram support is not finished yet, come back later`")
}
func (c *Client) DialStreamingContextFree(addr string) (net.Conn, error) {