diff --git a/fbb/wl2k.go b/fbb/wl2k.go index 2e3b97d..f071c9a 100644 --- a/fbb/wl2k.go +++ b/fbb/wl2k.go @@ -16,6 +16,7 @@ import ( "net" "os" "sort" + "strconv" "strings" "time" @@ -214,6 +215,13 @@ func (s *Session) Exchange(conn net.Conn) (stats TrafficStats, err error) { return stats, nil } + // Experimental support for fetching messages only for auxiliary addresses (not mycall). + // Ref https://groups.google.com/g/pat-users/c/5G1JIEyFXe4 + if t, _ := strconv.ParseBool(os.Getenv("FW_AUX_ONLY_EXPERIMENT")); t && len(s.localFW) > 1 { + s.localFW = s.localFW[1:] + s.log.Printf("FW_AUX_ONLY_EXPERIMENT: Requesting messages for %v", s.localFW) + } + // The given conn should always be closed after returning from this method. // If an error occurred, echo it to the remote. defer func() { diff --git a/fbb/wl2k_test.go b/fbb/wl2k_test.go index d6e478b..684fec4 100644 --- a/fbb/wl2k_test.go +++ b/fbb/wl2k_test.go @@ -8,6 +8,7 @@ import ( "bufio" "fmt" "net" + "os" "strings" "testing" ) @@ -46,6 +47,42 @@ func TestSessionP2P(t *testing.T) { } } +func TestFWAuxOnlyExperiment(t *testing.T) { + os.Setenv("FW_AUX_ONLY_EXPERIMENT", "1") + defer os.Setenv("FW_AUX_ONLY_EXPERIMENT", "0") + + client, master := net.Pipe() + + clientErr := make(chan error) + go func() { + s := NewSession("LA5NTA", "N0CALL", "JO39EQ", nil) + s.AddAuxiliaryAddress(AddressFromString("EMCOMM-1@winlink.org")) + _, err := s.Exchange(client) + clientErr <- err + }() + + masterErr := make(chan error) + go func() { + s := NewSession("N0CALL", "LA5NTA", "JO39EQ", nil) + s.IsMaster(true) + _, err := s.Exchange(master) + switch fw := s.RemoteForwarders(); { + case len(fw) != 1: + t.Errorf("unexpected FW count: %d", len(fw)) + case fw[0].String() != "EMCOMM-1": + t.Errorf("unexpected FW address: %q", fw[0]) + } + masterErr <- err + }() + + if err := <-masterErr; err != nil { + t.Errorf("Master returned with error: %s", err) + } + if err := <-clientErr; err != nil { + t.Errorf("Client returned with error: %s", err) + } +} + func TestSessionCMS(t *testing.T) { client, srv := net.Pipe()