Преглед на файлове

Fix missing error wrapping and typos

Rod Hynes преди 3 години
родител
ревизия
5882312663
променени са 3 файла, в които са добавени 20 реда и са изтрити 16 реда
  1. 1 3
      psiphon/common/prng/prng.go
  2. 18 11
      psiphon/common/protocol/serverEntry.go
  3. 1 2
      psiphon/server/udp.go

+ 1 - 3
psiphon/common/prng/prng.go

@@ -18,7 +18,6 @@
  */
 
 /*
-
 Package prng implements a seeded, unbiased PRNG that is suitable for use
 cases including obfuscation, network jitter, load balancing.
 
@@ -42,7 +41,6 @@ required for replay.
 
 PRNG conforms to io.Reader and math/rand.Source, with additional helper
 functions.
-
 */
 package prng
 
@@ -266,7 +264,7 @@ func (p *PRNG) ExpFloat64Range(min, max, lambda float64) float64 {
 	return value
 }
 
-// Intn is equivilent to math/rand.Perm.
+// Perm is equivilent to math/rand.Perm.
 func (p *PRNG) Perm(n int) []int {
 	return p.rand.Perm(n)
 }

+ 18 - 11
psiphon/common/protocol/serverEntry.go

@@ -487,7 +487,7 @@ func (serverEntry *ServerEntry) SupportsProtocol(protocol string) bool {
 // ProtocolUsesLegacyPassthrough indicates whether the ServerEntry supports
 // the specified protocol using legacy passthrough messages.
 //
-// There is no correspondong check for v2 passthrough, as clients send v2
+// There is no corresponding check for v2 passthrough, as clients send v2
 // passthrough messages unconditionally, by default, for passthrough
 // protocols.
 func (serverEntry *ServerEntry) ProtocolUsesLegacyPassthrough(protocol string) bool {
@@ -725,23 +725,31 @@ func TagToDiagnosticID(tag string) string {
 // EncodeServerEntry returns a string containing the encoding of
 // a ServerEntry following Psiphon conventions.
 func EncodeServerEntry(serverEntry *ServerEntry) (string, error) {
-	return encodeServerEntry(
+	encodedServerEntry, err := encodeServerEntry(
 		serverEntry.IpAddress,
 		serverEntry.WebServerPort,
 		serverEntry.WebServerSecret,
 		serverEntry.WebServerCertificate,
 		serverEntry)
+	if err != nil {
+		return "", errors.Trace(err)
+	}
+	return encodedServerEntry, nil
 }
 
 // EncodeServerEntryFields returns a string containing the encoding of
 // ServerEntryFields following Psiphon conventions.
 func EncodeServerEntryFields(serverEntryFields ServerEntryFields) (string, error) {
-	return encodeServerEntry(
+	encodedServerEntry, err := encodeServerEntry(
 		serverEntryFields.GetIPAddress(),
 		serverEntryFields.GetWebServerPort(),
 		serverEntryFields.GetWebServerSecret(),
 		serverEntryFields.GetWebServerCertificate(),
 		serverEntryFields)
+	if err != nil {
+		return "", errors.Trace(err)
+	}
+	return encodedServerEntry, nil
 }
 
 func encodeServerEntry(
@@ -940,14 +948,13 @@ func NewStreamingServerEntryDecoder(
 // input stream, returning a nil server entry when the stream is complete.
 //
 // Limitations:
-// - Each encoded server entry line cannot exceed bufio.MaxScanTokenSize,
-//   the default buffer size which this decoder uses. This is 64K.
-// - DecodeServerEntry is called on each encoded server entry line, which
-//   will allocate memory to hex decode and JSON deserialze the server
-//   entry. As this is not presently reusing a fixed buffer, each call
-//   will allocate additional memory; garbage collection is necessary to
-//   reclaim that memory for reuse for the next server entry.
-//
+//   - Each encoded server entry line cannot exceed bufio.MaxScanTokenSize,
+//     the default buffer size which this decoder uses. This is 64K.
+//   - DecodeServerEntry is called on each encoded server entry line, which
+//     will allocate memory to hex decode and JSON deserialze the server
+//     entry. As this is not presently reusing a fixed buffer, each call
+//     will allocate additional memory; garbage collection is necessary to
+//     reclaim that memory for reuse for the next server entry.
 func (decoder *StreamingServerEntryDecoder) Next() (ServerEntryFields, error) {
 
 	for {

+ 1 - 2
psiphon/server/udp.go

@@ -42,7 +42,6 @@ import (
 // The udpgw protocol and original server implementation:
 // Copyright (c) 2009, Ambroz Bizjak <ambrop7@gmail.com>
 // https://github.com/ambrop72/badvpn
-//
 func (sshClient *sshClient) handleUdpgwChannel(newChannel ssh.NewChannel) {
 
 	// Accept this channel immediately. This channel will replace any
@@ -264,7 +263,7 @@ func (mux *udpgwPortForwardMultiplexer) run() {
 			// Can't defer lruEntry.Remove() here;
 			// relayDownstream will call lruEntry.Remove()
 
-			// ActivityMonitoredConn monitors the TCP port forward I/O and updates
+			// ActivityMonitoredConn monitors the UDP port forward I/O and updates
 			// its LRU status. ActivityMonitoredConn also times out I/O on the port
 			// forward if both reads and writes have been idle for the specified
 			// duration.