Ver Fonte

Rename GetSpecName to SelectSpecName

Rod Hynes há 5 anos atrás
pai
commit
df03703c76

+ 3 - 3
psiphon/common/packetman/packetman.go

@@ -98,14 +98,14 @@ type Config struct {
 	// available for packet manipulation. Spec names must be unique.
 	Specs []*Spec
 
-	// GetSpecName is a callback invoked for each intercepted SYN-ACK packet.
-	// GetSpecName must return a name of a Spec, in Specs, to apply that
+	// SelectSpecName is a callback invoked for each intercepted SYN-ACK packet.
+	// SelectSpecName must return a name of a Spec, in Specs, to apply that
 	// transformation spec, or "" to send the SYN-ACK packet unmodified.
 	//
 	// The inputs protocolPort and clientIP allow the callback to select a Spec
 	// based on the protocol running at the intercepted packet's port and/or
 	// client GeoIP.
-	GetSpecName func(protocolPort int, clientIP net.IP) string
+	SelectSpecName func(protocolPort int, clientIP net.IP) string
 
 	// SudoNetworkConfigCommands specifies whether to use "sudo" when executing
 	// network configuration commands. See comment for same parameter in

+ 5 - 5
psiphon/common/packetman/packetman_linux.go

@@ -52,7 +52,7 @@ const (
 //
 // NFQUEUE/Netlink is used to intercept SYN-ACK packets, on all local
 // interfaces, with source port equal to one of the ProtocolPorts specified in
-// Config. For each intercepted SYN-ACK packet, the GetSpecName callback in
+// Config. For each intercepted SYN-ACK packet, the SelectSpecName callback in
 // Config is invoked; the callback determines which packet transformation spec
 // to apply, based on, for example, client GeoIP, protocol, or other
 // considerations.
@@ -352,9 +352,9 @@ func makeConnectionID(
 // TCP connection, represented by its local and remote address components,
 // that was ultimately accepted by a network listener.
 //
-// This allows GetSpecName, the spec selector, to be non-deterministic while
-// also allowing for accurate packet manipulation metrics to be associated
-// with each TCP connection.
+// This allows SelectSpecName, the spec selector, to be non-deterministic
+// while also allowing for accurate packet manipulation metrics to be
+// associated with each TCP connection.
 //
 // For a given connection, GetAppliedSpecName must be called before a TTL
 // clears the stored value. Calling GetAppliedSpecName immediately clears the
@@ -533,7 +533,7 @@ func (m *Manipulator) getCompiledSpec(interceptedPacket gopacket.Packet) (*compi
 	protocolPort := interceptedTCP.SrcPort
 	clientIP := dstIP
 
-	specName := m.config.GetSpecName(int(protocolPort), clientIP)
+	specName := m.config.SelectSpecName(int(protocolPort), clientIP)
 	if specName == "" {
 		return nil, nil
 	}

+ 1 - 1
psiphon/common/packetman/packetman_linux_test.go

@@ -81,7 +81,7 @@ func testPacketManipulator(useIPv6 bool, t *testing.T) {
 		Logger:        newTestLogger(),
 		ProtocolPorts: []int{listenerPort},
 		Specs:         []*Spec{&Spec{Name: testSpecName, PacketSpecs: [][]string{[]string{"TCP-flags S"}}}},
-		GetSpecName: func(protocolPort int, _ net.IP) string {
+		SelectSpecName: func(protocolPort int, _ net.IP) string {
 			if protocolPort == listenerPort {
 				return testSpecName
 			}

+ 2 - 2
psiphon/server/packetman.go

@@ -44,7 +44,7 @@ func makePacketManipulatorConfig(
 		}
 	}
 
-	getSpecName := func(protocolPort int, clientIP net.IP) string {
+	selectSpecName := func(protocolPort int, clientIP net.IP) string {
 
 		specName, err := selectPacketManipulationSpec(support, protocolPort, clientIP)
 		if err != nil {
@@ -68,7 +68,7 @@ func makePacketManipulatorConfig(
 		QueueNumber:               1,
 		ProtocolPorts:             ports,
 		Specs:                     specs,
-		GetSpecName:               getSpecName,
+		SelectSpecName:            selectSpecName,
 	}, nil
 }