mirror of
https://github.com/fhmq/hmq.git
synced 2026-08-30 14:24:53 +00:00
Rmoeve unnecessary type convert (#134)
This commit is contained in:
+4
-4
@@ -289,7 +289,7 @@ func (b *Broker) handleConnection(typ int, conn net.Conn) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if typ == CLIENT && !b.CheckConnectAuth(string(msg.ClientIdentifier), string(msg.Username), string(msg.Password)) {
|
if typ == CLIENT && !b.CheckConnectAuth(msg.ClientIdentifier, msg.Username, string(msg.Password)) {
|
||||||
connack.ReturnCode = packets.ErrRefusedNotAuthorised
|
connack.ReturnCode = packets.ErrRefusedNotAuthorised
|
||||||
func() {
|
func() {
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
@@ -360,8 +360,8 @@ func (b *Broker) handleConnection(typ int, conn net.Conn) {
|
|||||||
b.OnlineOfflineNotification(cid, true)
|
b.OnlineOfflineNotification(cid, true)
|
||||||
{
|
{
|
||||||
b.Publish(&bridge.Elements{
|
b.Publish(&bridge.Elements{
|
||||||
ClientID: string(msg.ClientIdentifier),
|
ClientID: msg.ClientIdentifier,
|
||||||
Username: string(msg.Username),
|
Username: msg.Username,
|
||||||
Action: bridge.Connect,
|
Action: bridge.Connect,
|
||||||
Timestamp: time.Now().Unix(),
|
Timestamp: time.Now().Unix(),
|
||||||
})
|
})
|
||||||
@@ -600,7 +600,7 @@ func (b *Broker) BroadcastSubOrUnsubMessage(packet packets.ControlPacket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *Broker) removeClient(c *client) {
|
func (b *Broker) removeClient(c *client) {
|
||||||
clientId := string(c.info.clientID)
|
clientId := c.info.clientID
|
||||||
typ := c.typ
|
typ := c.typ
|
||||||
switch typ {
|
switch typ {
|
||||||
case CLIENT:
|
case CLIENT:
|
||||||
|
|||||||
+1
-2
@@ -159,7 +159,6 @@ func LoadConfig(filename string) (*Config, error) {
|
|||||||
return &config, nil
|
return &config, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (p *Plugins) UnmarshalJSON(b []byte) error {
|
func (p *Plugins) UnmarshalJSON(b []byte) error {
|
||||||
var named NamedPlugins
|
var named NamedPlugins
|
||||||
err := json.Unmarshal(b, &named)
|
err := json.Unmarshal(b, &named)
|
||||||
@@ -235,7 +234,7 @@ func NewTLSConfig(tlsInfo TLSInfo) (*tls.Config, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
pool := x509.NewCertPool()
|
pool := x509.NewCertPool()
|
||||||
ok := pool.AppendCertsFromPEM([]byte(rootPEM))
|
ok := pool.AppendCertsFromPEM(rootPEM)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("failed to parse root ca certificate")
|
return nil, fmt.Errorf("failed to parse root ca certificate")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ func (this *Session) Init(msg *packets.ConnectPacket) error {
|
|||||||
|
|
||||||
this.topics = make(map[string]byte, 1)
|
this.topics = make(map[string]byte, 1)
|
||||||
|
|
||||||
this.id = string(msg.ClientIdentifier)
|
this.id = msg.ClientIdentifier
|
||||||
|
|
||||||
this.initted = true
|
this.initted = true
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user