Browse Source

go.crypto/ssh: add String method to RejectionReason.

R=agl, dave
CC=golang-dev
https://golang.org/cl/14494055
Han-Wen Nienhuys 12 năm trước cách đây
mục cha
commit
4a7557f2bd
1 tập tin đã thay đổi với 15 bổ sung0 xóa
  1. 15 0
      ssh/channel.go

+ 15 - 0
ssh/channel.go

@@ -77,6 +77,21 @@ const (
 	ResourceShortage
 )
 
+// String converts the rejection reason to human readable form.
+func (r RejectionReason) String() string {
+	switch r {
+	case Prohibited:
+		return "administratively prohibited"
+	case ConnectionFailed:
+		return "connect failed"
+	case UnknownChannelType:
+		return "unknown channel type"
+	case ResourceShortage:
+		return "resource shortage"
+	}
+	return fmt.Sprintf("unknown reason %d", int(r))
+}
+
 type channel struct {
 	packetConn        // the underlying transport
 	localId, remoteId uint32