瀏覽代碼

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

R=agl, dave
CC=golang-dev
https://golang.org/cl/14494055
Han-Wen Nienhuys 12 年之前
父節點
當前提交
4a7557f2bd
共有 1 個文件被更改,包括 15 次插入0 次删除
  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