Skip to content

Commit

Permalink
Make most packets to avoid confusion
Browse files Browse the repository at this point in the history
  • Loading branch information
fd committed Jan 8, 2015
1 parent 600d119 commit 643c353
Show file tree
Hide file tree
Showing 39 changed files with 76 additions and 79 deletions.
4 changes: 2 additions & 2 deletions _dht/chord/chord.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"github.com/armon/go-chord"

"github.com/telehash/gogotelehash/e3x"
"github.com/telehash/gogotelehash/hashname"
"github.com/telehash/gogotelehash/lob"
"github.com/telehash/gogotelehash/internal/hashname"
"github.com/telehash/gogotelehash/internal/lob"
"github.com/telehash/gogotelehash/modules/mesh"
)

Expand Down
2 changes: 1 addition & 1 deletion _dht/chord/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"io"

"github.com/telehash/gogotelehash/e3x"
"github.com/telehash/gogotelehash/lob"
"github.com/telehash/gogotelehash/internal/lob"
)

type stream struct {
Expand Down
4 changes: 2 additions & 2 deletions _dht/kademlia/kademlia.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package kademlia

import (
"github.com/telehash/gogotelehash/hashname"
"github.com/telehash/gogotelehash/lob"
"github.com/telehash/gogotelehash/internal/hashname"
"github.com/telehash/gogotelehash/internal/lob"
"sync"
"time"

Expand Down
28 changes: 14 additions & 14 deletions api.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package gogotelehash
package telehash

import (
"encoding/json"
"net"
"time"

"github.com/telehash/gogotelehash/e3x"
"github.com/telehash/gogotelehash/hashname"
"github.com/telehash/gogotelehash/lob"
"github.com/telehash/gogotelehash/internal/hashname"
"github.com/telehash/gogotelehash/internal/lob"
"github.com/telehash/gogotelehash/transports"

// "github.com/telehash/gogotelehash/modules/bridge"
"github.com/telehash/gogotelehash/modules/paths"
"github.com/telehash/gogotelehash/internal/modules/bridge"
"github.com/telehash/gogotelehash/internal/modules/paths"
)

type (
Expand All @@ -26,20 +26,16 @@ type (
Packet lob.Packet
)

// func Bridge() EndpointOption {
// return EndpointOption(bridge.Module())
// }

func Paths() EndpointOption {
return EndpointOption(paths.Module())
}

func Transport(config transports.Config) EndpointOption {
return EndpointOption(e3x.Transport(config))
}

func Open(options ...EndpointOption) (*Endpoint, error) {
innerOptions := make([]e3x.EndpointOption, len(options))
innerOptions := make([]e3x.EndpointOption, len(options)+10)

This comment has been minimized.

Copy link
@bondar-pavel

bondar-pavel May 29, 2018

Why have '+10' been added here?
It results in failure to setOptions at:

e3x.Open(innerOptions...)

And everything fails with panic...

This comment has been minimized.

Copy link
@fd

fd May 29, 2018

Author Contributor

That should probably be: innerOptions := make([]e3x.EndpointOption, len(options), len(options)+10)

This comment has been minimized.

Copy link
@bondar-pavel

bondar-pavel May 29, 2018

Right, in this case it would make much more sense, thanks.
Will create PR with the fix.

This comment has been minimized.

Copy link
@bondar-pavel

bondar-pavel May 29, 2018

I have a fix for that :)
#60

I know project is currently in a dead state, but I'll try to play with it until I find a good reason why it should not be alive.

This comment has been minimized.

Copy link
@fd

fd May 29, 2018

Author Contributor

Sure! Feel free to have some fun with this project 😉
Are you aware that there is a th v4 in development? (I must say I'm not sure what the state of that is)

This comment has been minimized.

Copy link
@bondar-pavel

bondar-pavel May 30, 2018

Well, it does not look like v4 went far away from initial commit 7 month ago :(
https://github.com/telehash/v4

So sticking with v3 at this point, and I hope latest gogotelehash master mostly implement v3 :)


innerOptions = append(innerOptions, paths.Module())
innerOptions = append(innerOptions, bridge.Module(bridge.Config{}))

for i, option := range options {
innerOptions[i] = e3x.EndpointOption(option)
}
Expand Down Expand Up @@ -196,3 +192,7 @@ func (i *Identity) Identify(e *e3x.Endpoint) (*e3x.Identity, error) {
func (p *Packet) Header() *lob.Header {
return (*lob.Packet)(p).Header()
}

func (p *Packet) Free() {
(*lob.Packet)(p).Free()
}
4 changes: 2 additions & 2 deletions e3x/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
"sync"
"time"

"github.com/telehash/gogotelehash/hashname"
"github.com/telehash/gogotelehash/internal/hashname"
"github.com/telehash/gogotelehash/internal/lob"
"github.com/telehash/gogotelehash/internal/util/tracer"
"github.com/telehash/gogotelehash/lob"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion e3x/channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (

"github.com/telehash/gogotelehash/Godeps/_workspace/src/github.com/stretchr/testify/assert"

"github.com/telehash/gogotelehash/internal/lob"
"github.com/telehash/gogotelehash/internal/util/logs"
"github.com/telehash/gogotelehash/lob"
"github.com/telehash/gogotelehash/transports/inproc"
"github.com/telehash/gogotelehash/transports/mux"
"github.com/telehash/gogotelehash/transports/udp"
Expand Down
2 changes: 1 addition & 1 deletion e3x/cipherset/cipher_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"crypto/sha256"
"errors"

"github.com/telehash/gogotelehash/lob"
"github.com/telehash/gogotelehash/internal/lob"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion e3x/cipherset/cs1a/cs1a_cipher.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (
"github.com/telehash/gogotelehash/e3x/cipherset/cs1a/eccp"
"github.com/telehash/gogotelehash/e3x/cipherset/cs1a/ecdh"
"github.com/telehash/gogotelehash/e3x/cipherset/cs1a/secp160r1"
"github.com/telehash/gogotelehash/internal/lob"
"github.com/telehash/gogotelehash/internal/util/bufpool"
"github.com/telehash/gogotelehash/lob"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion e3x/cipherset/cs3a/cs3a_cipher.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (
"github.com/telehash/gogotelehash/Godeps/_workspace/src/golang.org/x/crypto/poly1305"

"github.com/telehash/gogotelehash/e3x/cipherset"
"github.com/telehash/gogotelehash/internal/lob"
"github.com/telehash/gogotelehash/internal/util/base32util"
"github.com/telehash/gogotelehash/internal/util/bufpool"
"github.com/telehash/gogotelehash/lob"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion e3x/cipherset/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"encoding/json"
"errors"

"github.com/telehash/gogotelehash/internal/lob"
"github.com/telehash/gogotelehash/internal/util/base32util"
"github.com/telehash/gogotelehash/lob"
)

var ErrInvalidKeys = errors.New("chipherset: invalid keys")
Expand Down
2 changes: 1 addition & 1 deletion e3x/cipherset/tests/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/telehash/gogotelehash/Godeps/_workspace/src/github.com/stretchr/testify/suite"

"github.com/telehash/gogotelehash/e3x/cipherset"
"github.com/telehash/gogotelehash/lob"
"github.com/telehash/gogotelehash/internal/lob"
)

type cipherTestSuite struct {
Expand Down
2 changes: 1 addition & 1 deletion e3x/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"sync"

"github.com/telehash/gogotelehash/e3x/cipherset"
"github.com/telehash/gogotelehash/hashname"
"github.com/telehash/gogotelehash/internal/hashname"
"github.com/telehash/gogotelehash/internal/util/bufpool"
"github.com/telehash/gogotelehash/internal/util/logs"
"github.com/telehash/gogotelehash/internal/util/tracer"
Expand Down
4 changes: 2 additions & 2 deletions e3x/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (
"time"

"github.com/telehash/gogotelehash/e3x/cipherset"
"github.com/telehash/gogotelehash/hashname"
"github.com/telehash/gogotelehash/internal/hashname"
"github.com/telehash/gogotelehash/internal/lob"
"github.com/telehash/gogotelehash/internal/util/bufpool"
"github.com/telehash/gogotelehash/internal/util/logs"
"github.com/telehash/gogotelehash/internal/util/tracer"
"github.com/telehash/gogotelehash/lob"
"github.com/telehash/gogotelehash/transports"
)

Expand Down
2 changes: 1 addition & 1 deletion e3x/identifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package e3x
import (
"errors"

"github.com/telehash/gogotelehash/hashname"
"github.com/telehash/gogotelehash/internal/hashname"
)

var ErrUnidentifiable = errors.New("unidentifiable identity")
Expand Down
2 changes: 1 addition & 1 deletion e3x/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net"

"github.com/telehash/gogotelehash/e3x/cipherset"
"github.com/telehash/gogotelehash/hashname"
"github.com/telehash/gogotelehash/internal/hashname"
"github.com/telehash/gogotelehash/transports"
)

Expand Down
2 changes: 1 addition & 1 deletion e3x/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (

"github.com/telehash/gogotelehash/Godeps/_workspace/src/github.com/stretchr/testify/mock"

"github.com/telehash/gogotelehash/internal/lob"
"github.com/telehash/gogotelehash/internal/util/tracer"
"github.com/telehash/gogotelehash/lob"
)

type MockExchange struct {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion lob/header_coder.go → internal/lob/header_coder.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func parseUint32(p []byte) (uint32, []byte, bool) {

for idx, r := range p {
if '0' <= r && r <= '9' {
n = (n * 10) + (uint32(r) - '0')
n = n*10 + (uint32(r) - '0')
continue
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package bridge

import (
"github.com/telehash/gogotelehash/internal/util/bufpool"
"io"
"sync"
"time"

"github.com/telehash/gogotelehash/e3x"
"github.com/telehash/gogotelehash/e3x/cipherset"
"github.com/telehash/gogotelehash/hashname"
"github.com/telehash/gogotelehash/internal/hashname"
"github.com/telehash/gogotelehash/internal/util/bufpool"
"github.com/telehash/gogotelehash/internal/util/logs"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ package bridge
import (
"net"
"testing"
// "time"

"github.com/telehash/gogotelehash/Godeps/_workspace/src/github.com/stretchr/testify/assert"

"github.com/telehash/gogotelehash/e3x"
"github.com/telehash/gogotelehash/internal/lob"
"github.com/telehash/gogotelehash/internal/util/logs"
"github.com/telehash/gogotelehash/lob"
"github.com/telehash/gogotelehash/transports"
"github.com/telehash/gogotelehash/transports/fw"
"github.com/telehash/gogotelehash/transports/udp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (

"github.com/telehash/gogotelehash/e3x"
"github.com/telehash/gogotelehash/e3x/cipherset"
"github.com/telehash/gogotelehash/hashname"
"github.com/telehash/gogotelehash/internal/hashname"
"github.com/telehash/gogotelehash/internal/lob"
"github.com/telehash/gogotelehash/internal/util/bufpool"
"github.com/telehash/gogotelehash/internal/util/logs"
"github.com/telehash/gogotelehash/lob"
)

var mainLog = logs.Module("peers")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (

"github.com/telehash/gogotelehash/e3x"
"github.com/telehash/gogotelehash/e3x/cipherset"
"github.com/telehash/gogotelehash/hashname"
"github.com/telehash/gogotelehash/internal/hashname"
"github.com/telehash/gogotelehash/internal/lob"
"github.com/telehash/gogotelehash/internal/util/bufpool"
"github.com/telehash/gogotelehash/lob"
)

func (mod *module) peerVia(router *e3x.Exchange, to hashname.H, body *bufpool.Buffer) error {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net"

"github.com/telehash/gogotelehash/e3x"
"github.com/telehash/gogotelehash/hashname"
"github.com/telehash/gogotelehash/internal/hashname"
"github.com/telehash/gogotelehash/transports"
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package bridge

import (
"github.com/telehash/gogotelehash/internal/util/bufpool"
"io"
"net"
"sync"
"time"

"github.com/telehash/gogotelehash/e3x"
"github.com/telehash/gogotelehash/hashname"
"github.com/telehash/gogotelehash/lob"
"github.com/telehash/gogotelehash/internal/hashname"
"github.com/telehash/gogotelehash/internal/lob"
"github.com/telehash/gogotelehash/internal/util/bufpool"
"github.com/telehash/gogotelehash/transports/transportsutil"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"time"

"github.com/telehash/gogotelehash/e3x"
"github.com/telehash/gogotelehash/lob"
"github.com/telehash/gogotelehash/internal/lob"
"github.com/telehash/gogotelehash/transports"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/util/logs/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package logs
import (
"os"

"github.com/telehash/gogotelehash/hashname"
"github.com/telehash/gogotelehash/internal/hashname"
)

var defaultLogger = New(os.Stdout)
Expand Down
2 changes: 1 addition & 1 deletion internal/util/logs/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
"time"

"github.com/telehash/gogotelehash/hashname"
"github.com/telehash/gogotelehash/internal/hashname"
)

var disabledMods = map[string]bool{}
Expand Down
2 changes: 1 addition & 1 deletion modules/thtp/round_tripper.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strings"

"github.com/telehash/gogotelehash/e3x"
"github.com/telehash/gogotelehash/hashname"
"github.com/telehash/gogotelehash/internal/hashname"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion tools/th-keygen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

_ "github.com/telehash/gogotelehash/e3x"
"github.com/telehash/gogotelehash/e3x/cipherset"
"github.com/telehash/gogotelehash/hashname"
"github.com/telehash/gogotelehash/internal/hashname"
)

const usage = `Telehash key generation tool.
Expand Down
6 changes: 3 additions & 3 deletions tools/th-test/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ type Context struct {
Out io.Writer
}

func (c *Context) WriteIdentity(e *gogotelehash.Endpoint) {
func (c *Context) WriteIdentity(e *telehash.Endpoint) {
if c.dir == "" {
if _, err := os.Stat("/shared"); err == nil {
c.dir = "/shared"
Expand Down Expand Up @@ -170,7 +170,7 @@ func (c *Context) WriteIdentity(e *gogotelehash.Endpoint) {
}
}

func (c *Context) ReadIdentity(role string) *gogotelehash.Identity {
func (c *Context) ReadIdentity(role string) *telehash.Identity {

if c.dir == "" {
if _, err := os.Stat("/shared"); err == nil {
Expand All @@ -186,7 +186,7 @@ func (c *Context) ReadIdentity(role string) *gogotelehash.Identity {
os.Exit(1)
}

var ident *gogotelehash.Identity
var ident *telehash.Identity
err = json.Unmarshal(data, &ident)
if err != nil {
fmt.Printf("error: %s\n", err)
Expand Down
Loading

0 comments on commit 643c353

Please sign in to comment.