diff --git a/Makefile b/Makefile index 67e85845..5f69a823 100644 --- a/Makefile +++ b/Makefile @@ -19,8 +19,8 @@ raw-test: go test --tags nettest -v ./raw/... test-logs: - make common-test 2> common-err.log 1> common-out.log - make stream-test 2> stream-err.log 1> stream-out.log - make datagram-test 2> datagram-err.log 1> datagram-out.log - make raw-test 2> raw-err.log 1> raw-out.log - make primary-test 2> primary-err.log 1> primary-out.log + make common-test 2> common-err.log 1> common-out.log; cat common-err.log common-out.log + make stream-test 2> stream-err.log 1> stream-out.log; cat stream-err.log stream-out.log + #make datagram-test 2> datagram-err.log 1> datagram-out.log; cat datagram-err.log datagram-out.log + #make raw-test 2> raw-err.log 1> raw-out.log; cat raw-err.log raw-out.log + #make primary-test 2> primary-err.log 1> primary-out.log; cat primary-err.log primary-out.log diff --git a/common/emit-options.go b/common/emit-options.go index 28304f21..9eb0f4c4 100644 --- a/common/emit-options.go +++ b/common/emit-options.go @@ -414,9 +414,7 @@ func SetAccessListType(s string) func(*SAMEmit) error { func SetAccessList(s []string) func(*SAMEmit) error { return func(c *SAMEmit) error { if len(s) > 0 { - for _, a := range s { - c.I2PConfig.AccessList = append(c.I2PConfig.AccessList, a) - } + c.I2PConfig.AccessList = append(c.I2PConfig.AccessList, s...) log.WithField("accessList", s).Debug("Set access list") return nil } diff --git a/common/session.go b/common/session.go index 41d41e72..65c627df 100644 --- a/common/session.go +++ b/common/session.go @@ -31,26 +31,29 @@ func (sam SAM) NewGenericSessionWithSignature(style, id string, keys i2pkeys.I2P func (sam SAM) NewGenericSessionWithSignatureAndPorts(style, id, from, to string, keys i2pkeys.I2PKeys, sigType string, extras []string) (Session, error) { log.WithFields(logrus.Fields{"style": style, "id": id, "from": from, "to": to, "sigType": sigType}).Debug("Creating new generic session with signature and ports") - // Update SAM configuration with session-specific ports - sam.I2PConfig.Fromport = from - sam.I2PConfig.Toport = to + // Configure SAMEmit with all session parameters for message generation + sam.SAMEmit.I2PConfig.Style = style + sam.SAMEmit.I2PConfig.TunName = id + sam.SAMEmit.I2PConfig.DestinationKeys = &keys + sam.SAMEmit.I2PConfig.SigType = sigType + sam.SAMEmit.I2PConfig.Fromport = from + sam.SAMEmit.I2PConfig.Toport = to - optStr := sam.SamOptionsString() + // Generate the base SESSION CREATE message using emitter + baseMsg := strings.TrimSuffix(sam.SAMEmit.Create(), " \n") + + // Append any extra parameters if provided extraStr := strings.Join(extras, " ") + if extraStr != "" { + baseMsg += " " + extraStr + } - conn := sam.Conn - fp := "" - tp := "" - if from != "0" { - fp = " FROM_PORT=" + from - } - if to != "0" { - tp = " TO_PORT=" + to - } - scmsg := []byte("SESSION CREATE STYLE=" + style + fp + tp + " ID=" + id + " DESTINATION=" + keys.String() + " " + optStr + " " + extraStr + "\n") + // Create final message with proper line termination + scmsg := []byte(baseMsg + "\n") log.WithField("message", string(scmsg)).Debug("Sending SESSION CREATE message") + conn := sam.Conn n, err := conn.Write(scmsg) if err != nil { log.WithError(err).Error("Failed to write to SAM connection")