mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-15 00:19:29 +01:00
commit
507dc2d838
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@ -19,7 +19,7 @@ jobs:
|
|||||||
- name: "setup go"
|
- name: "setup go"
|
||||||
uses: "actions/setup-go@v2"
|
uses: "actions/setup-go@v2"
|
||||||
with:
|
with:
|
||||||
go-version: "1.18"
|
go-version: "1.19"
|
||||||
- name: "install python3-pytest"
|
- name: "install python3-pytest"
|
||||||
run: "sudo apt install -y python3-pytest"
|
run: "sudo apt install -y python3-pytest"
|
||||||
- name: "make install"
|
- name: "make install"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
## build ergo binary
|
## build ergo binary
|
||||||
FROM golang:1.18-alpine AS build-env
|
FROM golang:1.19-alpine AS build-env
|
||||||
|
|
||||||
RUN apk add -U --force-refresh --no-cache --purge --clean-protected -l -u make git
|
RUN apk add -U --force-refresh --no-cache --purge --clean-protected -l -u make git
|
||||||
|
|
||||||
|
2
go.mod
2
go.mod
@ -1,6 +1,6 @@
|
|||||||
module github.com/ergochat/ergo
|
module github.com/ergochat/ergo
|
||||||
|
|
||||||
go 1.18
|
go 1.19
|
||||||
|
|
||||||
require (
|
require (
|
||||||
code.cloudfoundry.org/bytefmt v0.0.0-20200131002437-cf55d5288a48
|
code.cloudfoundry.org/bytefmt v0.0.0-20200131002437-cf55d5288a48
|
||||||
|
@ -16,7 +16,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (server *Server) Config() (config *Config) {
|
func (server *Server) Config() (config *Config) {
|
||||||
return server.config.Get()
|
return server.config.Load()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (server *Server) ChannelRegistrationEnabled() bool {
|
func (server *Server) ChannelRegistrationEnabled() bool {
|
||||||
|
@ -15,6 +15,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -66,7 +67,7 @@ type Server struct {
|
|||||||
channels ChannelManager
|
channels ChannelManager
|
||||||
channelRegistry ChannelRegistry
|
channelRegistry ChannelRegistry
|
||||||
clients ClientManager
|
clients ClientManager
|
||||||
config utils.ConfigStore[Config]
|
config atomic.Pointer[Config]
|
||||||
configFilename string
|
configFilename string
|
||||||
connectionLimiter connection_limits.Limiter
|
connectionLimiter connection_limits.Limiter
|
||||||
ctime time.Time
|
ctime time.Time
|
||||||
@ -707,7 +708,7 @@ func (server *Server) applyConfig(config *Config) (err error) {
|
|||||||
config.Server.Cloaks.SetSecret(LoadCloakSecret(server.store))
|
config.Server.Cloaks.SetSecret(LoadCloakSecret(server.store))
|
||||||
|
|
||||||
// activate the new config
|
// activate the new config
|
||||||
server.config.Set(config)
|
server.config.Store(config)
|
||||||
|
|
||||||
// load [dk]-lines, registered users and channels, etc.
|
// load [dk]-lines, registered users and channels, etc.
|
||||||
if initial {
|
if initial {
|
||||||
|
@ -4,15 +4,17 @@
|
|||||||
|
|
||||||
// Package smtp implements the Simple Mail Transfer Protocol as defined in RFC 5321.
|
// Package smtp implements the Simple Mail Transfer Protocol as defined in RFC 5321.
|
||||||
// It also implements the following extensions:
|
// It also implements the following extensions:
|
||||||
|
//
|
||||||
// 8BITMIME RFC 1652
|
// 8BITMIME RFC 1652
|
||||||
// AUTH RFC 2554
|
// AUTH RFC 2554
|
||||||
// STARTTLS RFC 3207
|
// STARTTLS RFC 3207
|
||||||
|
//
|
||||||
// Additional extensions may be handled by clients.
|
// Additional extensions may be handled by clients.
|
||||||
//
|
//
|
||||||
// The smtp package is frozen and is not accepting new features.
|
// The smtp package is frozen and is not accepting new features.
|
||||||
// Some external packages provide more functionality. See:
|
// Some external packages provide more functionality. See:
|
||||||
//
|
//
|
||||||
// https://godoc.org/?q=smtp
|
// https://godoc.org/?q=smtp
|
||||||
package smtp
|
package smtp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -105,12 +105,13 @@ func (socket *Socket) Write(data []byte) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// BlockingWrite sends the given string out of Socket. Requirements:
|
// BlockingWrite sends the given string out of Socket. Requirements:
|
||||||
// 1. MUST block until the message is sent
|
// 1. MUST block until the message is sent
|
||||||
// 2. MUST bypass sendq (calls to BlockingWrite cannot, on their own, cause a sendq overflow)
|
// 2. MUST bypass sendq (calls to BlockingWrite cannot, on their own, cause a sendq overflow)
|
||||||
// 3. MUST provide mutual exclusion for socket.conn.Write
|
// 3. MUST provide mutual exclusion for socket.conn.Write
|
||||||
// 4. MUST respect the same ordering guarantees as Write (i.e., if a call to Write that sends
|
// 4. MUST respect the same ordering guarantees as Write (i.e., if a call to Write that sends
|
||||||
// message m1 happens-before a call to BlockingWrite that sends message m2,
|
// message m1 happens-before a call to BlockingWrite that sends message m2,
|
||||||
// m1 must be sent on the wire before m2
|
// m1 must be sent on the wire before m2
|
||||||
|
//
|
||||||
// Callers MUST be writing to the client's socket from the client's own goroutine;
|
// Callers MUST be writing to the client's socket from the client's own goroutine;
|
||||||
// other callers must use the nonblocking Write call instead. Otherwise, a client
|
// other callers must use the nonblocking Write call instead. Otherwise, a client
|
||||||
// with a slow/unreliable connection risks stalling the progress of the system as a whole.
|
// with a slow/unreliable connection risks stalling the progress of the system as a whole.
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
// Copyright (c) 2022 Shivaram Lingamneni
|
|
||||||
// released under the MIT license
|
|
||||||
|
|
||||||
package utils
|
|
||||||
|
|
||||||
import (
|
|
||||||
"sync/atomic"
|
|
||||||
"unsafe"
|
|
||||||
)
|
|
||||||
|
|
||||||
/*
|
|
||||||
This can be used to implement the following pattern:
|
|
||||||
|
|
||||||
1. Prepare a config object (this can be arbitrarily expensive)
|
|
||||||
2. Take a pointer to the config object and use Set() to install it
|
|
||||||
3. Use Get() to access the config from any goroutine
|
|
||||||
4. To update the config, call Set() again with a new prepared config object
|
|
||||||
5. As long as any individual config object is not modified (by any goroutine)
|
|
||||||
after it is installed with Set(), this is free of data races, and Get()
|
|
||||||
is extremely cheap (on amd64 it compiles down to plain MOV instructions).
|
|
||||||
*/
|
|
||||||
|
|
||||||
type ConfigStore[Config any] struct {
|
|
||||||
ptr unsafe.Pointer
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *ConfigStore[Config]) Get() *Config {
|
|
||||||
return (*Config)(atomic.LoadPointer(&c.ptr))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *ConfigStore[Config]) Set(ptr *Config) {
|
|
||||||
atomic.StorePointer(&c.ptr, unsafe.Pointer(ptr))
|
|
||||||
}
|
|
@ -203,7 +203,7 @@ func parseProxyLineV2(line []byte) (ip net.IP, err error) {
|
|||||||
return ip, nil
|
return ip, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
/// WrappedConn is a net.Conn with some additional data stapled to it;
|
// / WrappedConn is a net.Conn with some additional data stapled to it;
|
||||||
// the proxied IP, if one was read via the PROXY protocol, and the listener
|
// the proxied IP, if one was read via the PROXY protocol, and the listener
|
||||||
// configuration.
|
// configuration.
|
||||||
type WrappedConn struct {
|
type WrappedConn struct {
|
||||||
|
@ -22,9 +22,12 @@ type MessagePair struct {
|
|||||||
// SplitMessage represents a message that's been split for sending.
|
// SplitMessage represents a message that's been split for sending.
|
||||||
// Two possibilities:
|
// Two possibilities:
|
||||||
// (a) Standard message that can be relayed on a single 512-byte line
|
// (a) Standard message that can be relayed on a single 512-byte line
|
||||||
// (MessagePair contains the message, Split == nil)
|
//
|
||||||
|
// (MessagePair contains the message, Split == nil)
|
||||||
|
//
|
||||||
// (b) multiline message that was split on the client side
|
// (b) multiline message that was split on the client side
|
||||||
// (Message == "", Split contains the split lines)
|
//
|
||||||
|
// (Message == "", Split contains the split lines)
|
||||||
type SplitMessage struct {
|
type SplitMessage struct {
|
||||||
Message string
|
Message string
|
||||||
Msgid string
|
Msgid string
|
||||||
|
Loading…
Reference in New Issue
Block a user