Delete some unused functions
This commit is contained in:
43
emit.go
43
emit.go
@ -48,27 +48,6 @@ func (e *SAMEmit) LookupBytes(name string) []byte {
|
||||
return []byte(e.Lookup(name))
|
||||
}
|
||||
|
||||
func (e *SAMEmit) Create() string {
|
||||
create := fmt.Sprintf(
|
||||
// //1 2 3 4 5 6 7
|
||||
"SESSION CREATE %s%s%s%s%s%s%s \n",
|
||||
e.I2PConfig.SessionStyle(), // 1
|
||||
e.I2PConfig.FromPort(), // 2
|
||||
e.I2PConfig.ToPort(), // 3
|
||||
e.I2PConfig.ID(), // 4
|
||||
e.I2PConfig.DestinationKey(), // 5
|
||||
e.I2PConfig.SignatureType(), // 6
|
||||
e.OptStr(), // 7
|
||||
)
|
||||
log.WithField("create", create).Debug("Generated SESSION CREATE command")
|
||||
return create
|
||||
}
|
||||
|
||||
func (e *SAMEmit) CreateBytes() []byte {
|
||||
fmt.Println("sam command: " + e.Create())
|
||||
return []byte(e.Create())
|
||||
}
|
||||
|
||||
func (e *SAMEmit) Connect(dest string) string {
|
||||
connect := fmt.Sprintf(
|
||||
"STREAM CONNECT ID=%s %s %s DESTINATION=%s \n",
|
||||
@ -100,28 +79,6 @@ func (e *SAMEmit) AcceptBytes() []byte {
|
||||
return []byte(e.Accept())
|
||||
}
|
||||
|
||||
// Extend SAMEmit with additional command generation
|
||||
func (e *SAMEmit) GenerateSessionCmd(style string) string {
|
||||
cmd := &strings.Builder{}
|
||||
cmd.WriteString("SESSION CREATE ")
|
||||
cmd.WriteString(e.I2PConfig.SessionStyle())
|
||||
|
||||
if e.I2PConfig.FromPort() != "" {
|
||||
cmd.WriteString(" FROM_PORT=" + e.I2PConfig.FromPort())
|
||||
}
|
||||
|
||||
if e.I2PConfig.ToPort() != "" {
|
||||
cmd.WriteString(" TO_PORT=" + e.I2PConfig.ToPort())
|
||||
}
|
||||
|
||||
cmd.WriteString(e.I2PConfig.ID())
|
||||
cmd.WriteString(e.I2PConfig.DestinationKey())
|
||||
cmd.WriteString(e.OptStr())
|
||||
cmd.WriteString("\n")
|
||||
|
||||
return cmd.String()
|
||||
}
|
||||
|
||||
func NewEmit(opts ...func(*SAMEmit) error) (*SAMEmit, error) {
|
||||
var emit SAMEmit
|
||||
for _, o := range opts {
|
||||
|
13
sam3.go
13
sam3.go
@ -194,11 +194,11 @@ const (
|
||||
|
||||
func (sam *SAM) NewKeys(sigType ...string) (i2pkeys.I2PKeys, error) {
|
||||
log.WithField("sigType", sigType).Debug("Generating new keys")
|
||||
sigtmp := DEFAULT_SIG_TYPE
|
||||
if len(sigType) > 0 {
|
||||
sigtmp = sigType[0]
|
||||
if sigType == nil {
|
||||
sigType = []string{DEFAULT_SIG_TYPE}
|
||||
}
|
||||
if _, err := sam.conn.Write([]byte("DEST GENERATE " + sigtmp + "\n")); err != nil {
|
||||
scmsg := []byte(fmt.Sprintf("DEST GENERATE %s\n", sigType[0]))
|
||||
if _, err := sam.conn.Write(scmsg); err != nil {
|
||||
log.WithError(err).Error("Failed to write DEST GENERATE command")
|
||||
return i2pkeys.I2PKeys{}, fmt.Errorf("error with writing in SAM: %w", err)
|
||||
}
|
||||
@ -265,8 +265,11 @@ func (sam *SAM) newGenericSessionWithSignatureAndPorts(style, id, from, to strin
|
||||
|
||||
conn := sam.conn
|
||||
scmsg := []byte(fmt.Sprintf("SESSION CREATE STYLE=%s FROM_PORT=%s TO_PORT=%s ID=%s DESTINATION=%s %s %s\n", style, from, to, id, keys.String(), optStr, strings.Join(extras, " ")))
|
||||
if style == "PRIMARY" || style == "MASTER" {
|
||||
scmsg = []byte(fmt.Sprintf("SESSION CREATE STYLE=%s ID=%s DESTINATION=%s %s %s\n", style, id, keys.String(), optStr, strings.Join(extras, " ")))
|
||||
}
|
||||
|
||||
log.WithField("message", string(scmsg)).Debug("Sending SESSION CREATE message")
|
||||
log.WithField("message", string(scmsg)).Debug("Sending SESSION CREATE message", string(scmsg))
|
||||
|
||||
for m, i := 0, 0; m != len(scmsg); i++ {
|
||||
if i == 15 {
|
||||
|
Reference in New Issue
Block a user