Skip to content

Commit

Permalink
fbb: FW_AUX_ONLY_EXPERIMENT
Browse files Browse the repository at this point in the history
Experimental support for requesting messages on behalf of auxiliary
addresses only (not mycall).

Ref la5nta/pat#428
  • Loading branch information
martinhpedersen committed Nov 4, 2023
1 parent f11f6c0 commit 793eeec
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
8 changes: 8 additions & 0 deletions fbb/wl2k.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"net"
"os"
"sort"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -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() {
Expand Down
37 changes: 37 additions & 0 deletions fbb/wl2k_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"bufio"
"fmt"
"net"
"os"
"strings"
"testing"
)
Expand Down Expand Up @@ -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("[email protected]"))
_, 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()

Expand Down

0 comments on commit 793eeec

Please sign in to comment.