5 Commits

Author SHA1 Message Date
idk
c7d6848930 Protext non-context-aware dialer with a mutex 2020-08-25 10:31:44 -04:00
idk
eabd2d94f6 Protext non-context-aware dialer with a mutex 2020-08-25 10:27:40 -04:00
idk
76924e5961 add make link target 2020-07-29 13:00:36 -04:00
idk
027983674b add Makefile to help me automate releases 2020-07-29 12:57:16 -04:00
idk
7521a7862a Fix multi-lookup utility 2020-07-29 12:54:09 -04:00
8 changed files with 51 additions and 4 deletions

24
Makefile Normal file
View File

@@ -0,0 +1,24 @@
USER_GH=eyedeekay
VERSION=0.32.23
packagename=gosam
echo:
@echo "type make version to do release $(VERSION)"
version:
gothub release -s $(GITHUB_TOKEN) -u $(USER_GH) -r $(packagename) -t v$(VERSION) -d "version $(VERSION)"
del:
gothub delete -s $(GITHUB_TOKEN) -u $(USER_GH) -r $(packagename) -t v$(VERSION)
tar:
tar --exclude .git \
--exclude .go \
--exclude bin \
--exclude examples \
-cJvf ../$(packagename)_$(VERSION).orig.tar.xz .
link:
rm -f ../goSam
ln -sf . ../goSam

View File

@@ -11,6 +11,7 @@ import (
"math/rand"
"net"
"strings"
"sync"
)
// A Client represents a single Connection to the SAM bridge
@@ -52,6 +53,7 @@ type Client struct {
//NEVER, EVER modify lastaddr or id yourself. They are used internally only.
lastaddr string
id int32
ml sync.Mutex
}
var SAMsigTypes = []string{

7
debian/changelog vendored
View File

@@ -1,3 +1,10 @@
golang-github-eyedeekay-gosam (0.32.23) bionic; urgency=medium
* Get rid of the debug directory, just move it into the source
* Get rid of the old example, just use the one in the README
-- idk <hankhill19580@gmail.com> Tue, 25 Aug 2020 10:29:26 -0500
golang-github-eyedeekay-gosam (0.3.2.1) bionic; urgency=medium
* Get rid of the debug directory, just move it into the source

3
debian/control vendored
View File

@@ -6,7 +6,8 @@ Uploaders: idk <hankhill19580@gmail.com>
Build-Depends: debhelper (>= 11),
dh-golang,
golang-any,
i2pd | i2p
i2pd | i2p,
git,
Standards-Version: 4.2.1
Homepage: https://github.com/eyedeekay/gosam
Vcs-Browser: https:/github.com/eyedeekay/gosam

1
debian/files vendored Normal file
View File

@@ -0,0 +1 @@
golang-github-eyedeekay-gosam_0.3.2.1_source.buildinfo devel optional

View File

@@ -34,18 +34,23 @@ func (c Client) dialCheck(addr string) (int32, bool) {
if c.lastaddr == "invalid" {
fmt.Println("Preparing to dial new address.")
return c.NewID(), true
} else if c.lastaddr != addr {
fmt.Println("Preparing to dial next new address.")
return c.NewID(), true
}
return c.id, false
}
// Dial implements the net.Dial function and can be used for http.Transport
func (c *Client) Dial(network, addr string) (net.Conn, error) {
c.ml.Lock()
portIdx := strings.Index(addr, ":")
if portIdx >= 0 {
addr = addr[:portIdx]
}
addr, err := c.Lookup(addr)
if err != nil {
c.ml.Unlock()
return nil, err
}
@@ -53,18 +58,22 @@ func (c *Client) Dial(network, addr string) (net.Conn, error) {
if c.id, test = c.dialCheck(addr); test == true {
c.destination, err = c.CreateStreamSession(c.id, c.destination)
if err != nil {
c.ml.Unlock()
return nil, err
}
c.lastaddr = addr
}
c, err = c.NewClient()
if err != nil {
c.ml.Unlock()
return nil, err
}
err = c.StreamConnect(c.id, addr)
if err != nil {
c.ml.Unlock()
return nil, err
}
c.ml.Unlock()
return c.SamConn, nil
}

3
go.sum Normal file
View File

@@ -0,0 +1,3 @@
github.com/eyedeekay/ramp v0.0.0-20190429201811-305b382042ab/go.mod h1:h7mvUAMgZ/rtRDUOkvKTK+8LnDMeUhJSoa5EPdB51fc=
github.com/eyedeekay/sam3 v0.32.2 h1:xODDY5nBVg0oK7KaYk7ofkXFoHPsmI1umhSv1TZlS7s=
github.com/eyedeekay/sam3 v0.32.2/go.mod h1:Y3igFVzN4ybqkkpfUWULGhw7WRp8lieq0ORXbLBbcZM=

View File

@@ -22,8 +22,8 @@ func TestClientLookupInvalid(t *testing.T) {
if !ok {
t.Fatalf("client.Lookup() should return a ReplyError")
}
if repErr.Result != ResultInvalidKey {
t.Errorf("client.Lookup() should throw an ResultKeyNotFound error.\nGot:%+v\n", repErr)
if repErr.Result != ResultKeyNotFound {
t.Errorf("client.Lookup() should throw an ResultKeyNotFound error.\nGot:%+v%s%s\n", repErr, "!=", ResultKeyNotFound)
}
}
@@ -46,5 +46,5 @@ func ExampleClient_Lookup() {
// Output:
//Address of zzz.i2p:
//GKapJ8koUcBj~jmQzHsTYxDg2tpfWj0xjQTzd8BhfC9c3OS5fwPBNajgF-eOD6eCjFTqTlorlh7Hnd8kXj1qblUGXT-tDoR9~YV8dmXl51cJn9MVTRrEqRWSJVXbUUz9t5Po6Xa247Vr0sJn27R4KoKP8QVj1GuH6dB3b6wTPbOamC3dkO18vkQkfZWUdRMDXk0d8AdjB0E0864nOT~J9Fpnd2pQE5uoFT6P0DqtQR2jsFvf9ME61aqLvKPPWpkgdn4z6Zkm-NJOcDz2Nv8Si7hli94E9SghMYRsdjU-knObKvxiagn84FIwcOpepxuG~kFXdD5NfsH0v6Uri3usE3uSzpWS0EHmrlfoLr5uGGd9ZHwwCIcgfOATaPRMUEQxiK9q48PS0V3EXXO4-YLT0vIfk4xO~XqZpn8~PW1kFe2mQMHd7oO89yCk-3yizRG3UyFtI7-mO~eCI6-m1spYoigStgoupnC3G85gJkqEjMm49gUjbhfWKWI-6NwTj0ZnAAAA
//GKapJ8koUcBj~jmQzHsTYxDg2tpfWj0xjQTzd8BhfC9c3OS5fwPBNajgF-eOD6eCjFTqTlorlh7Hnd8kXj1qblUGXT-tDoR9~YV8dmXl51cJn9MVTRrEqRWSJVXbUUz9t5Po6Xa247Vr0sJn27R4KoKP8QVj1GuH6dB3b6wTPbOamC3dkO18vkQkfZWUdRMDXk0d8AdjB0E0864nOT~J9Fpnd2pQE5uoFT6P0DqtQR2jsFvf9ME61aqLvKPPWpkgdn4z6Zkm-NJOcDz2Nv8Si7hli94E9SghMYRsdjU-knObKvxiagn84FIwcOpepxuG~kFXdD5NfsH0v6Uri3usE3XWD7Pw6P8qVYF39jUIq4OiNMwPnNYzy2N4mDMQdsdHO3LUVh~DEppOy9AAmEoHDjjJxt2BFBbGxfdpZCpENkwvmZeYUyNCCzASqTOOlNzdpne8cuesn3NDXIpNnqEE6Oe5Qm5YOJykrX~Vx~cFFT3QzDGkIjjxlFBsjUJyYkFjBQAEAAcAAA==
}