shuo-docs/Users.md

2.5 KiB

Once you've set up your Shou server, it's time to add your first users. Open your config.js and set public to false. This will enable user login.

When you start Shout in "private" mode it will load every user found in your users/ folder. Here's some of the features users get:

  • Stay online on IRC even when you log out
  • Lets you chat from multiple devices simultaneously

Add user

To add a new user, run this command:

$ shuo add <name>

This will create a new user in your users/ folder.

Note: By default, users are stored in the ~/.shout/users/ folder. You can change this location by using the --home <path> setting (see Usage).

Edit user

Open the user.json for the specified user:

$ shuo edit <name>

Remove user

Simply run:

$ shuo remove <name>

List users

This command will print a list of all your existing users:

$ shuo list

User configuration

If you run shuo edit <name>, the user.json file will open.

The user configuration is loaded upon server start. Here's an example of what a user.json file might look like:

{
  "user": "example",
  "password": "password",
  "log": false,
  "networks": [{
    "name": "Freenode",
    "host": "irc.freenode.net",
    "port": 6697,
    "tls": true,
    "password": "serverpw",
    "nick": "john",
    "realname": "John Doe",
    "commands": [
      "/msg NickServ identify password",
      "/msg ChanServ op #chan"
    ],
    "join": "#foo, #bar"
	}]
}

For those interested in automating account creation, an account can also be represented by the following Go structure:

type User struct {
    Username string     `json:"user"`
    Password string     `json:"password"`
    Log      bool       `json:"log"`
    Networks []*Network `json:"networks"`
}
type Network struct {
    Name     string `json:"name"`
    Host     string `json:"host"`
    Port     string `json:"port"`
    TLS      bool   `json:"tls"`
    Username string `json:"username"`
    Realname string `json:"realname"`
    Nick     string `json:"nick"`
    Join     string `json:"join"`
}

Passwords must be encrypted using bcrypt. The following code fragment is known to work for generating valid passwords:

import "golang.org/x/crypto/bcrypt"

func clear(b []byte) {
    for i := 0; i < len(b); i++ {
        b[i] = 0
    }
}
func Crypt(password []byte) ([]byte, error) {
    defer clear(password)
    return bcrypt.GenerateFromPassword(password, bcrypt.DefaultCost)
}