Renamed RecvOnly to Monitor

This commit is contained in:
blackbeard420 2025-03-03 20:24:18 -05:00
parent 1e10152db4
commit 0fc25eb941
2 changed files with 34 additions and 13 deletions

View File

@ -4,9 +4,11 @@ ouchnets official relay client
## usage ## usage
ouch-relay simply opens config.json in the current directory currently. a CLI has not been added yet `./ouch-relay` will load config.json from current directory
`./ouch-relay` To specify config path use `./ouch-relay -cfg path/to/config`
`./ouch-relay -h` to print the usage message
## config ## config
@ -15,15 +17,24 @@ ouch-relay simply opens config.json in the current directory currently. a CLI ha
"networks": [ "networks": [
{ {
"url": "irc.ouch.chat:6667", "url": "irc.ouch.chat:6667",
"nick": "relay1", "nick": "Alpha",
"channel": "#testing", "channel": "#testing",
"name": "ouchNET", "name": "TestNet",
"monitor": true
}, },
{ {
"url": "irc.whatever.chat:6667", "url": "irc.ouch.chat:6667",
"nick": "relay2", "nick": "Beta",
"channel": "#test", "channel": "#test",
"name": "whateverNET", "name": "OuchNet",
"monitor": false
},
{
"url": "irc.ouch.chat:6667",
"nick": "Charlie",
"channel": "#taliban",
"name": "TalibanNet",
"monitor": false
} }
] ]
} }
@ -33,6 +44,6 @@ ouch-relay simply opens config.json in the current directory currently. a CLI ha
- `nick` is the nickname you want the relay to use - `nick` is the nickname you want the relay to use
- `channel` is the channel you want the relay to occupy - `channel` is the channel you want the relay to occupy
- `name` is the network Identifier for the relay - `name` is the network Identifier for the relay
- `recvonly` set to `true` to make connection only recieve relays, not send - `monitor` set to `true` to make connection only recieve messages from relay chain, not send
you may specify as many networks as you want under the json `"netoworks"` array. All networks will then have specified channels relayed across all networks you may specify as many networks as you want under the json `"networks"` array. All networks will then have specified channels relayed across all networks

View File

@ -2,6 +2,7 @@ package main
import ( import (
"encoding/json" "encoding/json"
"flag"
"fmt" "fmt"
"log" "log"
"os" "os"
@ -17,7 +18,7 @@ type Network struct {
Nick string `json:"nick"` Nick string `json:"nick"`
Channel string `json:"channel"` Channel string `json:"channel"`
Name string `json:"name"` Name string `json:"name"`
RecvOnly bool `json:"recvonly"` Monitor bool `json:"monitor"`
Connection irc.Connection Connection irc.Connection
} }
@ -29,7 +30,16 @@ var netmap map[string]*Network
var netmutex sync.Mutex var netmutex sync.Mutex
func main() { func main() {
buf, _ := os.ReadFile("config.json") cfgpath := flag.String("cfg", "config.json", "path to config file")
flag.Parse()
log.Printf("Loading config: %s", *cfgpath)
buf, err := os.ReadFile(*cfgpath)
if err != nil {
log.Fatalf("FATAL: %s", err.Error())
}
conf := Config{} conf := Config{}
@ -55,7 +65,7 @@ func initRelay(n *Network) {
netmap[n.Name] = n netmap[n.Name] = n
n.Connection = *irc.NewConnection(n.Url, n.Nick, n.Nick, nil, []string{n.Channel}) n.Connection = *irc.NewConnection(n.Url, n.Nick, n.Nick, nil, []string{n.Channel})
if !n.RecvOnly { if !n.Monitor {
n.Connection.PrivmsgCallbackEx = handleMessage n.Connection.PrivmsgCallbackEx = handleMessage
n.Connection.JoinCallbackEx = handleJoin n.Connection.JoinCallbackEx = handleJoin
n.Connection.PartCallbackEx = handlePart n.Connection.PartCallbackEx = handlePart
@ -73,7 +83,7 @@ func deleteRelay(n string) {
func runRelay(n *Network) { func runRelay(n *Network) {
n.Connection.Run() n.Connection.Run()
relay(&n.Connection, "Network connection lost, retrying in 15 seconds") log.Printf("Network connection lost [%s]", n.Name)
time.Sleep(time.Second * 15) time.Sleep(time.Second * 15)
initRelay(n) initRelay(n)
} }