Skip to content
This repository was archived by the owner on Oct 2, 2022. It is now read-only.

Commit a17f469

Browse files
author
Janos Pasztor
committed
Message code cleanup
1 parent 7b2d246 commit a17f469

File tree

7 files changed

+45
-29
lines changed

7 files changed

+45
-29
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.9.8: Message code cleanup
4+
5+
This release cleans up the message codes being emitted.
6+
37
## 0.9.7: Bugfixing validation
48

59
This release fixes a validation bug introduced in the previous version where TLS parameters were validated even if the URL didn't point to a `https://` URL.

CODES.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
# Message/error codes
1+
# Message / error codes
22

33
| Code | Explanation |
4-
| `HTTP_CLIENT_CONNECTION_FAILED` | Sending a HTTP request failed for reasons outside of ContainerSSH |
5-
| `HTTP_CLIENT_DECODE_FAILED` | ContainerSSH failed to decode the JSON response after sending a request. Check if the HTTP server is misbehaving. |
6-
| `HTTP_CLIENT_ENCODE_FAILED` | ContainerSSH failed to encode the payload for sending a HTTP request. This is a bug, please file an issue. |
7-
| `HTTP_CLIENT_REDIRECTS_DISABLED` | ContainerSSH is refusing to follow a HTTP redirect received because the `allowRedirects` option is disabled. |
8-
| `HTTP_CLIENT_REDIRECT` | ContainerSSH has received a HTTP redirect from the server. |
9-
| `HTTP_CLIENT_RESPONSE` | ContainerSSH has received a response to a HTTP request sent to a server. |
10-
| `HTTP_CLIENT_REQUEST` | ContainerSSH is sending a HTTP request to a server. |
4+
|------|-------------|
5+
| `HTTP_CLIENT_CONNECTION_FAILED` | This message indicates a connection failure on the network level. |
6+
| `HTTP_CLIENT_DECODE_FAILED` | This message indicates that decoding the JSON response has failed. The status code is set for this code. |
7+
| `HTTP_CLIENT_ENCODE_FAILED` | This message indicates that JSON encoding the request failed. This is usually a bug. |
8+
| `HTTP_CLIENT_REDIRECT` | This message indicates that the server responded with a HTTP redirect. |
9+
| `HTTP_CLIENT_REDIRECTS_DISABLED` | This message indicates that ContainerSSH is not following a HTTP redirect sent by the server. Use the allowRedirects option to allow following HTTP redirects. |
10+
| `HTTP_CLIENT_REQUEST` | This message indicates that a HTTP request is being sent from ContainerSSH |
11+
| `HTTP_CLIENT_RESPONSE` | This message indicates that ContainerSSH received a HTTP response from a server. |
12+

codes.go

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
package http
22

3-
const (
4-
// EFailureEncodeFailed indicates that JSON encoding the request failed. This is usually a bug.
5-
EFailureEncodeFailed = "HTTP_CLIENT_ENCODE_FAILED"
6-
// EFailureConnectionFailed indicates a connection failure on the network level.
7-
EFailureConnectionFailed = "HTTP_CLIENT_CONNECTION_FAILED"
8-
// EFailureDecodeFailed indicates that decoding the JSON response has failed. The status code is set for this
9-
// code.
10-
EFailureDecodeFailed = "HTTP_CLIENT_DECODE_FAILED"
11-
// EClientRedirectsDisabled indicates that ContainerSSH is not following a HTTP redirect sent by the server.
12-
EClientRedirectsDisabled = "HTTP_CLIENT_REDIRECTS_DISABLED"
3+
// This message indicates that JSON encoding the request failed. This is usually a bug.
4+
const EFailureEncodeFailed = "HTTP_CLIENT_ENCODE_FAILED"
135

14-
// MClientRequest is a message indicating a HTTP request sent from ContainerSSH
15-
MClientRequest = "HTTP_CLIENT_REQUEST"
6+
// This message indicates a connection failure on the network level.
7+
const EFailureConnectionFailed = "HTTP_CLIENT_CONNECTION_FAILED"
168

17-
// MClientRedirect indicates that the server has sent a HTTP redirect.
18-
MClientRedirect = "HTTP_CLIENT_REDIRECT"
9+
// This message indicates that decoding the JSON response has failed. The status code is set for this
10+
// code.
11+
const EFailureDecodeFailed = "HTTP_CLIENT_DECODE_FAILED"
1912

20-
// MClientResponse is a message indicating receiving a HTTP response to a client request
21-
MClientResponse = "HTTP_CLIENT_RESPONSE"
22-
)
13+
// This message indicates that ContainerSSH is not following a HTTP redirect sent by the server. Use the allowRedirects
14+
// option to allow following HTTP redirects.
15+
const EClientRedirectsDisabled = "HTTP_CLIENT_REDIRECTS_DISABLED"
16+
17+
// This message indicates that a HTTP request is being sent from ContainerSSH
18+
const MClientRequest = "HTTP_CLIENT_REQUEST"
19+
20+
// This message indicates that the server responded with a HTTP redirect.
21+
const MClientRedirect = "HTTP_CLIENT_REDIRECT"
22+
23+
// This message indicates that ContainerSSH received a HTTP response from a server.
24+
const MClientResponse = "HTTP_CLIENT_RESPONSE"

codes_doc.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package http
2+
3+
//go:generate containerssh-generate-codes

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ module github.com/containerssh/http
33
go 1.14
44

55
require (
6-
github.com/containerssh/log v0.9.11
7-
github.com/containerssh/service v0.9.2
6+
github.com/containerssh/log v0.9.13
7+
github.com/containerssh/service v0.9.3
88
github.com/containerssh/structutils v0.9.0
99
github.com/stretchr/testify v1.7.0
1010
)

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@ github.com/containerssh/log v0.9.10 h1:c5cYbopsWKX+f5AdDCeMHaRQmkFexpAEgY8MlpLMk
66
github.com/containerssh/log v0.9.10/go.mod h1:NBMzkhOLZ4z45ShSBKQ/Ij6Hqqg15DgOKy6HlSITx0s=
77
github.com/containerssh/log v0.9.11 h1:CLpl9mhxBg4giLZjcZB+FjddYypm2f2x1bCY3iissdA=
88
github.com/containerssh/log v0.9.11/go.mod h1:uVuUPoZsJYi2KoV9+lgPeB/gWuXeUTD3AoVxc4y+tKY=
9+
github.com/containerssh/log v0.9.13 h1:jBSrFaxZNGwkjHU6y/efYI8lyG8KIFR5aOIeOnNzquE=
10+
github.com/containerssh/log v0.9.13/go.mod h1:uVuUPoZsJYi2KoV9+lgPeB/gWuXeUTD3AoVxc4y+tKY=
911
github.com/containerssh/service v0.9.0 h1:JUHqiK12tclq7EWQYGRTfgKKw6fhHs0gxlKWTvVwFlQ=
1012
github.com/containerssh/service v0.9.0/go.mod h1:otAKYF1MWy2eB0K7Sk7YQIECQMTHR3yikbyS1UstGpY=
1113
github.com/containerssh/service v0.9.2 h1:+EZ7s7sxSme+IosYBR24oNhVlPTz3GJTXBZ0HaSD9rU=
1214
github.com/containerssh/service v0.9.2/go.mod h1:nbA2I+GL0vU7ls0JEQKI+QOJfbUjlIDmmUSQqx/G7ro=
15+
github.com/containerssh/service v0.9.3 h1:mYpvZ9zxUrKL8OpBen86heXfGtdUGdtfZ3Y7P605zvQ=
16+
github.com/containerssh/service v0.9.3/go.mod h1:Yeq3hwfM6js9TfpkrQAQhv5IRfurrGEkM+AbFEC9KCE=
1317
github.com/containerssh/structutils v0.9.0 h1:pz4xl5ZrPnpdSx7B/ru8Fj3oU3vOtx1jprIuSkm5s7o=
1418
github.com/containerssh/structutils v0.9.0/go.mod h1:zirdwNXan3kuTpsJp9Gl3W6VQz0fexqMySqxmfviSjw=
1519
github.com/creasty/defaults v1.5.1 h1:j8WexcS3d/t4ZmllX4GEkl4wIB/trOr035ajcLHCISM=

server.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
)
1111

1212
// ServerConfiguration is a structure to configure the simple HTTP server by.
13+
//goland:noinspection GoVetStructTag
1314
type ServerConfiguration struct {
1415
// Listen contains the IP and port to listen on.
1516
Listen string `json:"listen" yaml:"listen" default:"0.0.0.0:8080"`
@@ -22,9 +23,9 @@ type ServerConfiguration struct {
2223
ClientCACert string `json:"clientcacert" yaml:"clientcacert"`
2324

2425
// cert is for internal use only. It contains the key and certificate after Validate.
25-
cert *tls.Certificate
26+
cert *tls.Certificate `json:"-" yaml:"-"`
2627
// clientCAPool is for internal use only. It contains the client CA pool after Validate.
27-
clientCAPool *x509.CertPool
28+
clientCAPool *x509.CertPool `json:"-" yaml:"-"`
2829
}
2930

3031
// Validate validates the server configuration.

0 commit comments

Comments
 (0)