美文网首页
无标题文章

无标题文章

作者: ddatsh | 来源:发表于2017-08-30 00:54 被阅读1次

package main

import (
"log"
"os"

"github.com/troian/surgemq"
"github.com/troian/surgemq/auth"
"github.com/troian/surgemq/persistence/types"
"github.com/troian/surgemq/transport"

)

type anonymousAuth struct {
}

func (a anonymousAuth) Password(user, password string) auth.Status {

return auth.StatusAllow

}

func (a anonymousAuth) ACL(clientID, user, topic string, access auth.AccessType) auth.Status {
return auth.StatusAllow
}

func main() {

var err error
var srv surgemq.Server
ia := anonymousAuth{}

serverConfig := surgemq.NewServerConfig()
serverConfig.Authenticators = "internal"
if err = auth.Register("internal", ia); err != nil {
    log.Printf("Couldn't register *internal* auth provider %s", err)
    os.Exit(1)
}

serverConfig.Persistence = &persistenceTypes.MemConfig{}
srv, err = surgemq.NewServer(serverConfig)
if err != nil {
    log.Printf("Couldn't create server %s", err)
    os.Exit(1)
}

var authMng *auth.Manager

if authMng, err = auth.NewManager("internal"); err != nil {
    log.Printf("Couldn't register *amqp* auth provider %s", err)
    return
}

config := transport.NewConfigTCP(
    &transport.Config{
        Port:        1883,
        AuthManager: authMng,
    })
if err = srv.ListenAndServe(config); err != nil {
    log.Printf("Couldn't start listener %s", err)
}
select {

}

}

相关文章

  • 无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章 无标题文章无标题文章无标题文章无...

  • 无标题文章

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章

  • 无标题文章

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标...

  • 无标题文章

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标...

  • fasfsdfdf

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标...

  • 无标题文章

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标...

  • 无标题文章

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标...

  • 无标题文章

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标...

  • 无标题文章

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章

  • 无标题文章

    无标题文章 无标题文章 无标题文章无标题文章 无标题文章 无标题文章

网友评论

      本文标题:无标题文章

      本文链接:https://www.haomeiwen.com/subject/msczdxtx.html