Просмотр исходного кода

Fix: underlying conn wrapped with normalizer

mirokuratczyk 2 лет назад
Родитель
Сommit
d8f91aecdc
1 измененных файлов с 23 добавлено и 3 удалено
  1. 23 3
      psiphon/server/meek.go

+ 23 - 3
psiphon/server/meek.go

@@ -1644,9 +1644,19 @@ func (conn *meekConn) GetUnderlyingTCPAddrs() (*net.TCPAddr, *net.TCPAddr, bool)
 
 // SetReplay implements the common.FragmentorReplayAccessor interface, applying
 // the inputs to the _first_ underlying TCP connection in the meek tunnel. If
-// the underlying connection is closed, the SetSeed call will have no effect.
+// the underlying connection is closed, then SetSeed call will have no effect.
 func (conn *meekConn) SetReplay(PRNG *prng.PRNG) {
-	fragmentor, ok := conn.firstUnderlyingConn.(common.FragmentorReplayAccessor)
+	underlyingConn := conn.firstUnderlyingConn
+
+	if conn.meekServer.normalizer != nil {
+		// The underlying conn is wrapped with a normalizer.
+		normalizer, ok := conn.meekSession.underlyingConn.(*transforms.HTTPNormalizer)
+		if ok {
+			underlyingConn = normalizer.Conn
+		}
+	}
+
+	fragmentor, ok := underlyingConn.(common.FragmentorReplayAccessor)
 	if ok {
 		fragmentor.SetReplay(PRNG)
 	}
@@ -1660,7 +1670,17 @@ func (conn *meekConn) SetReplay(PRNG *prng.PRNG) {
 // packet manipulation, any selected packet manipulation spec would have been
 // successful.
 func (conn *meekConn) GetReplay() (*prng.Seed, bool) {
-	fragmentor, ok := conn.firstUnderlyingConn.(common.FragmentorReplayAccessor)
+	underlyingConn := conn.firstUnderlyingConn
+
+	if conn.meekServer.normalizer != nil {
+		// The underlying conn is wrapped with a normalizer.
+		normalizer, ok := conn.meekSession.underlyingConn.(*transforms.HTTPNormalizer)
+		if ok {
+			underlyingConn = normalizer.Conn
+		}
+	}
+
+	fragmentor, ok := underlyingConn.(common.FragmentorReplayAccessor)
 	if ok {
 		return fragmentor.GetReplay()
 	}