Changeset 48 in code for trunk/partage.go


Ignore:
Timestamp:
Oct 20, 2021, 7:44:48 PM (4 years ago)
Author:
dev
Message:

Rename "bind" parameter to "listen"

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/partage.go

    r46 r48  
    4141        group    string
    4242        chroot   string
    43         bind     string
     43        listen     string
    4444        baseuri  string
    4545        rootdir  string
     
    255255        }
    256256
    257         conf.bind = cfg.Section("").Key("bind").String()
     257        conf.listen = cfg.Section("").Key("listen").String()
    258258        conf.user = cfg.Section("").Key("user").String()
    259259        conf.group = cfg.Section("").Key("group").String()
     
    298298
    299299        /* default values */
    300         conf.bind = "0.0.0.0:8080"
     300        conf.listen = "0.0.0.0:8080"
    301301        conf.baseuri = "http://127.0.0.1:8080"
    302302        conf.rootdir = "static"
     
    327327        }
    328328
    329         if conf.bind[0] == '/' {
    330                 listener, err = net.Listen("unix", conf.bind)
     329        if conf.listen[0] == '/' {
     330                listener, err = net.Listen("unix", conf.listen)
    331331                if err != nil {
    332332                        log.Fatal(err)
     
    334334
    335335                /* Ensure unix socket is removed on exit */
    336                 defer os.Remove(conf.bind)
     336                defer os.Remove(conf.listen)
    337337                sigs := make(chan os.Signal, 1)
    338338                signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
    339339                go func() {
    340340                        _ = <-sigs
    341                         os.Remove(conf.bind)
     341                        os.Remove(conf.listen)
    342342                        os.Exit(0)
    343343                }()
    344344        } else {
    345                 listener, err = net.Listen("tcp", conf.bind)
     345                listener, err = net.Listen("tcp", conf.listen)
    346346                if err != nil {
    347347                        log.Fatal(err)
     
    359359
    360360                if listener.Addr().Network() == "unix" {
    361                         os.Chown(conf.bind, uid, gid)
     361                        os.Chown(conf.listen, uid, gid)
    362362                }
    363363
     
    370370
    371371        if verbose {
    372                 log.Printf("Listening on %s", conf.bind)
     372                log.Printf("Listening on %s", conf.listen)
    373373        }
    374374
Note: See TracChangeset for help on using the changeset viewer.