Skip to content

Commit

Permalink
Use default host addr for tcp listeners
Browse files Browse the repository at this point in the history
Signed-off-by: Artur Troian <[email protected]>
  • Loading branch information
troian committed May 17, 2018
1 parent 52606c6 commit b4eaeba
Show file tree
Hide file tree
Showing 8 changed files with 154 additions and 3 deletions.
18 changes: 18 additions & 0 deletions certs/cert.crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-----BEGIN CERTIFICATE-----
MIIC+DCCAeACCQCA1rYfFUG7JzANBgkqhkiG9w0BAQsFADA+MQswCQYDVQQGEwJV
QTENMAsGA1UECAwES3lpdjENMAsGA1UEBwwES3lpdjERMA8GA1UECgwIVm9sYW50
TVEwHhcNMTgwNDE5MTUxNzM0WhcNMjEwMjA2MTUxNzM0WjA+MQswCQYDVQQGEwJV
QTENMAsGA1UECAwES3lpdjENMAsGA1UEBwwES3lpdjERMA8GA1UECgwIVm9sYW50
TVEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCvEw4fskikVCFKAgvb
DZnVngr0d0yqTHGgsqVRnAow54Nh+x4bx3r9zAjfw0leUxVs4TCT1twflNjW0MfV
GI+Su2YWPKbqHOloljWdKkhd/zTqfmBhQnGCpt1b7UdVjPw6LaoGRpDdOkvlocYD
+K45k0b7IV8Uz8AKgyTcsf8Ogybf5GCJLYjWFUOM76gt9dvhTvkhErEntXHUUIUl
G3PucL+L7hO+sBPIg5BMpd5vpEqDchfycUhVu894sRGnQlGnXdBbPUo6Monnh6Gk
FENzI4wd4oPGykIe60QhKibfmRt7DDKZ6fbH2ftK1h7pZmmoCgMOsTeTlgOdjLsT
Eq4TAgMBAAEwDQYJKoZIhvcNAQELBQADggEBAJ8pEPd150/G/KNAz7zdn/ItUS+4
fiU1lmc8DC2KBzw3P76JA8tTnpR4dhhi2w+IyhVlY2AtkFG2LrV1xwzoNvip/bCR
0DKgvCTk/5FK65bL5rrv2xILGzUR3EBTeZArhJcxdMaiqTQZ4XyOXgBXCg2z0CdA
ZJm78ecMTS8GApVKiA+E68pQ7FnTjdvq/a3b/pUh8PQGyyL6Z7ZNRVqWe/Cs1V1U
Z49XWSfXzLT2AuoI5UUxEwA2wxqSD3HPE8zyRilD9N+qqTboQTwmO75EHDqNl2ID
Ap/xsmYMyzjJ0RF5lI9GQ3K8SW/ZzRGU3O5lThN6JWijyT8LupyE/TVHELA=
-----END CERTIFICATE-----
27 changes: 27 additions & 0 deletions certs/cert.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEArxMOH7JIpFQhSgIL2w2Z1Z4K9HdMqkxxoLKlUZwKMOeDYfse
G8d6/cwI38NJXlMVbOEwk9bcH5TY1tDH1RiPkrtmFjym6hzpaJY1nSpIXf806n5g
YUJxgqbdW+1HVYz8Oi2qBkaQ3TpL5aHGA/iuOZNG+yFfFM/ACoMk3LH/DoMm3+Rg
iS2I1hVDjO+oLfXb4U75IRKxJ7Vx1FCFJRtz7nC/i+4TvrATyIOQTKXeb6RKg3IX
8nFIVbvPeLERp0JRp13QWz1KOjKJ54ehpBRDcyOMHeKDxspCHutEISom35kbewwy
men2x9n7StYe6WZpqAoDDrE3k5YDnYy7ExKuEwIDAQABAoIBAHEHZVvzV1C4fBFy
xsKywjmW4k24Y8eiuM1d6LuKeU3fegQdAvA+VlpaivQj+U8rZq63qAwacFz3VRND
EXCzfaXm1N7QY5bL+akrKQwBy1zcMgaedoz0P6JxJoJ960sBTaol5xpMHqSlSXDE
g7n2qEzFl9L0VZVzFvHyfy74v8lWsq4Ut4QiYwT+B2rnFDQMVyFCDOp1VM58Qei2
mh27dHGafxiF4Vs/MLUZpZNRVG7Ylv/1g1xjbDT/Q9PC5RCFguYiS5xbOiQ/Sv6Q
YoC2ktmnU+sVLibGvGkNhwcvpwavO0zmn2Tsa93yR3wcnw8EOO2EgFcMyxFZMVIe
6rR5e1ECgYEA5xs45AGIRBDsnGgs/0Ws9O6tIWbqwFeZVGjED9EwEYDG+fAbcJ37
SejW11lU5dsd9WNqT+hYB1h0gP2FgDBQRHiJlWtKZj0U1epAgd6paTEG0KlRwoH5
0A6xXtfHlFnUgx6UMl/bHFBOehGnfvO6GHvQf4n0TJagry3IE+AA5SsCgYEAwe6/
jVhNL3nzmzNQkncstL5ith0p8qQqRUMtVA3vycNvPFq7e6E20ydBWOsLwWrTMry3
Jr9dbsCYinDYAbdCFxVl2omt423hpR5GTQQG3yt5+mVB2xkvawpEUGMdChnvfisG
ag05tC8C7Pkkx53NCcXr2ejLEClAgi0N/EdCNrkCgYAK0oaGft/fuB8sb+Bzj9K6
oZav8r7ZhQCkKEfOKdCjcTFgMPNIAc3rtyCgcwl7vhgYDrDCzzGYHndONxESYLDR
lAd1XNHeGcwo/FBLBJ9QUsBr8xHmFuoY6Sc7NsWc19wQy9TKyxxaphQWuU7rrgQv
81RfNJmhIIijy3QMIjhIgwKBgE7icKRsAKmJL6A31VReiZ7Tuo9deYyrXk5iLvP7
30fw6TRhq9V0FDr7wscKhPOeIl6HCPEH8ld0nBfkItk/0/BT0eR9EHBsZ9akY/A7
7RemNa22tn0K15Dw0izoxA0x04s8sRU+X/R9EvGVvnI8LAUHrxIqcT8XqJfK/99Y
lQRxAoGBANZrCqRXSxcMdWy7cKRc9xM5tVKGeaCTR/36z6GqTQbLahfdfW5yGa+w
BQhbbnn3RsaA+G8QXX7+c2UyQWoU6xfi1olvCA7WAAUub0x1xu6ogLmJ3nbj5nG7
Ppl6TxQbDwAFlHANWJR4PB7FTpXLr1Y6OI8okw8TCWk6LoDhq2+k
-----END RSA PRIVATE KEY-----
1 change: 1 addition & 0 deletions clients/sessions.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ func (m *Manager) processConnect(cn connection.Initial, params *connection.Conne
// TODO(troian): verify method is allowed
} else {
var reason packet.ReasonCode

if status := authMngr.Password(string(params.Username), string(params.Password)); status == vlauth.StatusAllow {
reason = packet.CodeSuccess
} else {
Expand Down
101 changes: 101 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
version: v0.0.1
system:
log:
console:
config:
level: info # available levels: debug, info, warn, error, dpanic, panic, fatal
profiler:
port: 6060
cpu: true
mem: false
mutex: false
plugins:
enabled:
# - persistence_boltdb
- controller_auth
config:
# persistence: # plugin type
# - backend: boltdb # plugin internal name
# config:
# file: "persistence/data/bolt.db"
auth: # plugin type
- name: internal # authenticator name, used by listeners
backend: simpleAuth # authenticator type
config:
users:
testuser: "9f735e0df9a1ddc702bf0a1a7b83033f9f7153a00c29de82cedadc9957289b05" # password must be sha-256 hashed
# usersFile: "./users.yaml" # path to file with users: passwords
- name: "simply.amqp"
backend: "simply.amqp"
config:
schemas: "/Users/amr/projects/gocode/src/gitlab.com/trysimply/cloud/controller_auth/schema"
reqTimeout: 5
reconnect:
attempts: -1
period: 5
exchanges:
- name: events
type: topic
durable : true
autoDelete: false
internal: false
nowait: false
auth:
anonymous: true
order:
- internal
- simply.amqp
mqtt:
version:
- v3.1.1
- v3.1
keepAlive:
period: 60 # KeepAlive The number of seconds to keep the connection live if there's no data.
# Default is 60 seconds
force: false # Force connection to use server keep alive interval (MQTT 5.0 only)
# Default is false
systree:
enabled: true # Either systree available or not
# Default is false
updateInterval: 10 # Systree update interval
# Default is 10 seconds
options:
connectTimeout: 5 # The number of seconds to wait for the CONNECT message before disconnecting.
# If not set then default to 2 seconds.
offlineQoS0: true # OfflineQoS0 tell server to either persist (true) or ignore (false) QoS 0 messages for non-clean sessions
# If not set than default is false
sessionDups: true # AllowDuplicates Either allow or deny replacing of existing session if there new client with same clientID
# If not set than default is false
retainAvail: true # don't set to use default
subsOverlap: false # tells server how to handle overlapping subscriptions from within one client
# if true server will send only one publish with max subscribed QoS even there are n subscriptions
# if false server will send as many publishes as amount of subscriptions matching publish topic exists
# Default is false
subsId: false # don't set to use default
subsShared: false # don't set to use default
subsWildcard: true # don't set to use default
receiveMax: 65535 # don't set to use default
maxPacketSize: 268435455 # don't set to use default
maxTopicAlias: 65535 # don't set to use default
maxQoS: 2
listeners:
defaultAddr: "0.0.0.0" # default 127.0.0.1
mqtt:
tcp:
1883:
def: ""
ssl:
8884:
tls:
cert: "./certs/cert.crt"
key: "./certs/cert.key"
minVersion:
# ws:
# 8883:
# path: "ws"
# wss:
# 8884:
# path: "ws"
# tls:
# cert: "./certs/cert.pem"
# key: "./certs/key.pem"
3 changes: 3 additions & 0 deletions configuration/config_schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{

}
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func loadAuth(cfg *configuration.Config, plTypes pluginTypes) (*auth.Manager, er
}

if len(cfg.Auth.Order) == 0 {
logger.Fatalf("\tdefault auth order should not be empty auth.defaultOrder")
logger.Fatalf("\tdefault auth order should not be empty auth.Order")
return nil, errors.New("")
}

Expand Down Expand Up @@ -397,7 +397,7 @@ func main() {
if err == nil {
if config.System.Profiler.Port != "" {
profServer = &http.Server{
Addr: "localhost:" + config.System.Profiler.Port,
Addr: ":" + config.System.Profiler.Port,
}

logger.Info("profiler: serving at: ", "http://"+profServer.Addr+"/debug/pprof")
Expand Down
2 changes: 1 addition & 1 deletion transport/tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func NewTCP(config *ConfigTCP, internal *InternalConfig) (Provider, error) {

var err error

if l.listener, err = net.Listen(config.Scheme, config.transport.Host+":"+config.transport.Port); err != nil {
if l.listener, err = net.Listen(config.Scheme, ":"+config.transport.Port); err != nil {
return nil, err
}

Expand Down
1 change: 1 addition & 0 deletions users.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
testuser1: "4156649e224b76c295fca6c5fd46f233a9a8ef98d16a87d33c15b2696bc9524d"

0 comments on commit b4eaeba

Please sign in to comment.