2 Commits

Author SHA1 Message Date
idk
56cca2e537 bump version 2022-08-08 18:09:36 -04:00
idk
9ca67baa32 don't let the primary session thing be a guess, detect first, then attempt one and cache the result 2022-08-08 17:43:43 -04:00
3 changed files with 22 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
USER_GH=eyedeekay
VERSION=0.33.3
VERSION=0.33.4
packagename=sam3
echo:

View File

@@ -171,7 +171,11 @@ func (sam *PrimarySession) ResolveUDPAddr(network, dest string) (net.Addr, error
// Creates a new PrimarySession with the I2CP- and streaminglib options as
// specified. See the I2P documentation for a full list of options.
func (sam *SAM) NewPrimarySession(id string, keys i2pkeys.I2PKeys, options []string) (*PrimarySession, error) {
conn, err := sam.newGenericSession(PrimarySessionSwitch, id, keys, options, []string{})
return sam.newPrimarySession(PrimarySessionSwitch, id, keys, options)
}
func (sam *SAM) newPrimarySession(primarySessionSwitch string, id string, keys i2pkeys.I2PKeys, options []string) (*PrimarySession, error) {
conn, err := sam.newGenericSession(primarySessionSwitch, id, keys, options, []string{})
if err != nil {
return nil, err
}

View File

@@ -65,6 +65,22 @@ func PrimarySessionString() string {
if err != nil {
return "MASTER"
}
// at this point we're probably running on Java I2P and thus probably
// have a PRIMARY session. Just to be sure, try to make one, check
// for errors, then immediately close it.
testSam, err := NewSAM(SAMDefaultAddr(""))
if err != nil {
return "MASTER"
}
newKeys, err := testSam.NewKeys()
if err != nil {
return "MASTER"
}
primarySession, err := testSam.newPrimarySession("PRIMARY", "primaryTestTunnel", newKeys, Options_Small)
if err != nil {
return "MASTER"
}
primarySession.Close()
return "PRIMARY"
}
return "MASTER"