Changeset 612 in code for trunk/config/config.go


Ignore:
Timestamp:
Oct 7, 2021, 6:43:10 PM (4 years ago)
Author:
contact
Message:

Add max-user-networks config option

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/config/config.go

    r507 r612  
    55        "net"
    66        "os"
     7        "strconv"
    78
    89        "git.sr.ht/~emersion/go-scfg"
     
    3738
    3839type Server struct {
    39         Listen         []string
    40         Hostname       string
    41         TLS            *TLS
    42         SQLDriver      string
    43         SQLSource      string
    44         LogPath        string
     40        Listen   []string
     41        Hostname string
     42        TLS      *TLS
     43
     44        SQLDriver string
     45        SQLSource string
     46        LogPath   string
     47
    4548        HTTPOrigins    []string
    4649        AcceptProxyIPs IPSet
     50
     51        MaxUserNetworks int
    4752}
    4853
     
    5358        }
    5459        return &Server{
    55                 Hostname:  hostname,
    56                 SQLDriver: "sqlite3",
    57                 SQLSource: "soju.db",
     60                Hostname:        hostname,
     61                SQLDriver:       "sqlite3",
     62                SQLSource:       "soju.db",
     63                MaxUserNetworks: -1,
    5864        }
    5965}
     
    114120                                srv.AcceptProxyIPs = append(srv.AcceptProxyIPs, n)
    115121                        }
     122                case "max-user-networks":
     123                        var max string
     124                        if err := d.ParseParams(&max); err != nil {
     125                                return nil, err
     126                        }
     127                        var err error
     128                        if srv.MaxUserNetworks, err = strconv.Atoi(max); err != nil {
     129                                return nil, fmt.Errorf("directive %q: %v", d.Name, err)
     130                        }
    116131                default:
    117132                        return nil, fmt.Errorf("unknown directive %q", d.Name)
Note: See TracChangeset for help on using the changeset viewer.