Compare commits
1
Commits
next
..
b4d798005e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b4d798005e |
+1
-2
@@ -1,5 +1,4 @@
|
|||||||
# .git is sent so the build can stamp the version, without its config.
|
.git
|
||||||
.git/config
|
|
||||||
*.md
|
*.md
|
||||||
!README.md
|
!README.md
|
||||||
neoircd
|
neoircd
|
||||||
|
|||||||
+2
-13
@@ -39,19 +39,8 @@ COPY --from=web-builder /web/dist/ web/dist/
|
|||||||
RUN make test
|
RUN make test
|
||||||
|
|
||||||
# Build static binaries (no cgo needed at runtime — modernc.org/sqlite is pure Go)
|
# Build static binaries (no cgo needed at runtime — modernc.org/sqlite is pure Go)
|
||||||
#
|
ARG VERSION=dev
|
||||||
# neoircd is stamped with the VERSION build arg when one is given, otherwise
|
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w -X main.Version=${VERSION}" -o /neoircd ./cmd/neoircd/
|
||||||
# with the tag or short commit from the .git in the build context. With .git
|
|
||||||
# present, a version that is still empty, dev or unknown fails the build.
|
|
||||||
ARG VERSION
|
|
||||||
RUN VERSION="${VERSION:-$(git describe --tags --always)}"; \
|
|
||||||
if [ -e .git ]; then \
|
|
||||||
case "$VERSION" in ""|dev|unknown) \
|
|
||||||
echo "version is '$VERSION' although .git is present" >&2; \
|
|
||||||
exit 1 ;; \
|
|
||||||
esac; \
|
|
||||||
fi; \
|
|
||||||
CGO_ENABLED=0 go build -trimpath -ldflags="-s -w -X main.Version=${VERSION}" -o /neoircd ./cmd/neoircd/
|
|
||||||
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /neoirc-cli ./cmd/neoirc-cli/
|
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /neoirc-cli ./cmd/neoirc-cli/
|
||||||
|
|
||||||
# Runtime stage
|
# Runtime stage
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ fmt-check:
|
|||||||
@test -z "$$(gofmt -l .)" || (echo "Files not formatted:" && gofmt -l . && exit 1)
|
@test -z "$$(gofmt -l .)" || (echo "Files not formatted:" && gofmt -l . && exit 1)
|
||||||
|
|
||||||
test: ensure-web-dist
|
test: ensure-web-dist
|
||||||
go test -timeout 120s -race -cover ./... || go test -timeout 120s -race -v ./...
|
go test -timeout 30s -race -cover ./... || go test -timeout 30s -race -v ./...
|
||||||
|
|
||||||
# check runs all validation without making changes
|
# check runs all validation without making changes
|
||||||
# Used by CI and Docker build — fails if anything is wrong
|
# Used by CI and Docker build — fails if anything is wrong
|
||||||
|
|||||||
@@ -128,11 +128,7 @@ func (c *Conn) deliverIRCMessage(
|
|||||||
default:
|
default:
|
||||||
// Unknown command — deliver as server notice.
|
// Unknown command — deliver as server notice.
|
||||||
if text != "" {
|
if text != "" {
|
||||||
c.mu.Lock()
|
c.sendFromServer("NOTICE", c.nick, text)
|
||||||
nick := c.nick
|
|
||||||
c.mu.Unlock()
|
|
||||||
|
|
||||||
c.sendFromServer("NOTICE", nick, text)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -162,12 +158,8 @@ func (c *Conn) deliverNumeric(
|
|||||||
_ = json.Unmarshal(msg.Params, ¶ms)
|
_ = json.Unmarshal(msg.Params, ¶ms)
|
||||||
}
|
}
|
||||||
|
|
||||||
c.mu.Lock()
|
|
||||||
nick := c.nick
|
|
||||||
c.mu.Unlock()
|
|
||||||
|
|
||||||
allParams := make([]string, 0, 1+len(params)+1)
|
allParams := make([]string, 0, 1+len(params)+1)
|
||||||
allParams = append(allParams, nick)
|
allParams = append(allParams, c.nick)
|
||||||
allParams = append(allParams, params...)
|
allParams = append(allParams, params...)
|
||||||
|
|
||||||
if text != "" {
|
if text != "" {
|
||||||
@@ -185,12 +177,8 @@ func (c *Conn) deliverTextMessage(
|
|||||||
from := msg.From
|
from := msg.From
|
||||||
target := msg.To
|
target := msg.To
|
||||||
|
|
||||||
c.mu.Lock()
|
|
||||||
nick := c.nick
|
|
||||||
c.mu.Unlock()
|
|
||||||
|
|
||||||
// Don't echo our own messages back.
|
// Don't echo our own messages back.
|
||||||
if strings.EqualFold(from, nick) {
|
if strings.EqualFold(from, c.nick) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,13 +192,9 @@ func (c *Conn) deliverTextMessage(
|
|||||||
|
|
||||||
// deliverJoin sends a JOIN notification.
|
// deliverJoin sends a JOIN notification.
|
||||||
func (c *Conn) deliverJoin(msg *db.IRCMessage) {
|
func (c *Conn) deliverJoin(msg *db.IRCMessage) {
|
||||||
c.mu.Lock()
|
|
||||||
nick := c.nick
|
|
||||||
c.mu.Unlock()
|
|
||||||
|
|
||||||
// Don't echo our own JOINs (we already sent them
|
// Don't echo our own JOINs (we already sent them
|
||||||
// during joinChannel).
|
// during joinChannel).
|
||||||
if strings.EqualFold(msg.From, nick) {
|
if strings.EqualFold(msg.From, c.nick) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,11 +206,7 @@ func (c *Conn) deliverJoin(msg *db.IRCMessage) {
|
|||||||
|
|
||||||
// deliverPart sends a PART notification.
|
// deliverPart sends a PART notification.
|
||||||
func (c *Conn) deliverPart(msg *db.IRCMessage, text string) {
|
func (c *Conn) deliverPart(msg *db.IRCMessage, text string) {
|
||||||
c.mu.Lock()
|
if strings.EqualFold(msg.From, c.nick) {
|
||||||
nick := c.nick
|
|
||||||
c.mu.Unlock()
|
|
||||||
|
|
||||||
if strings.EqualFold(msg.From, nick) {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,11 +227,7 @@ func (c *Conn) deliverNickChange(
|
|||||||
msg *db.IRCMessage,
|
msg *db.IRCMessage,
|
||||||
newNick string,
|
newNick string,
|
||||||
) {
|
) {
|
||||||
c.mu.Lock()
|
if strings.EqualFold(msg.From, c.nick) {
|
||||||
nick := c.nick
|
|
||||||
c.mu.Unlock()
|
|
||||||
|
|
||||||
if strings.EqualFold(msg.From, nick) {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,11 +241,7 @@ func (c *Conn) deliverQuitMsg(
|
|||||||
msg *db.IRCMessage,
|
msg *db.IRCMessage,
|
||||||
text string,
|
text string,
|
||||||
) {
|
) {
|
||||||
c.mu.Lock()
|
if strings.EqualFold(msg.From, c.nick) {
|
||||||
nick := c.nick
|
|
||||||
c.mu.Unlock()
|
|
||||||
|
|
||||||
if strings.EqualFold(msg.From, nick) {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -330,11 +302,7 @@ func (c *Conn) deliverInviteMsg(
|
|||||||
_ *db.IRCMessage,
|
_ *db.IRCMessage,
|
||||||
text string,
|
text string,
|
||||||
) {
|
) {
|
||||||
c.mu.Lock()
|
c.sendFromServer("NOTICE", c.nick, text)
|
||||||
nick := c.nick
|
|
||||||
c.mu.Unlock()
|
|
||||||
|
|
||||||
c.sendFromServer("NOTICE", nick, text)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// deliverMode sends a MODE change notification.
|
// deliverMode sends a MODE change notification.
|
||||||
|
|||||||
@@ -71,14 +71,7 @@ func New(
|
|||||||
lifecycle.Append(fx.Hook{
|
lifecycle.Append(fx.Hook{
|
||||||
OnStart: func(_ context.Context) error {
|
OnStart: func(_ context.Context) error {
|
||||||
srv.startupTime = time.Now()
|
srv.startupTime = time.Now()
|
||||||
|
go srv.Run() //nolint:contextcheck
|
||||||
// Build the router before OnStart returns, so srv can
|
|
||||||
// handle requests as soon as the app has started.
|
|
||||||
srv.configure()
|
|
||||||
srv.enableSentry()
|
|
||||||
srv.SetupRoutes()
|
|
||||||
|
|
||||||
go srv.serve() //nolint:contextcheck
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
@@ -90,6 +83,13 @@ func New(
|
|||||||
return srv, nil
|
return srv, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Run starts the server configuration, Sentry, and begins serving.
|
||||||
|
func (srv *Server) Run() {
|
||||||
|
srv.configure()
|
||||||
|
srv.enableSentry()
|
||||||
|
srv.serve()
|
||||||
|
}
|
||||||
|
|
||||||
// ServeHTTP delegates to the chi router.
|
// ServeHTTP delegates to the chi router.
|
||||||
func (srv *Server) ServeHTTP(
|
func (srv *Server) ServeHTTP(
|
||||||
writer http.ResponseWriter,
|
writer http.ResponseWriter,
|
||||||
@@ -202,6 +202,8 @@ func (srv *Server) serveUntilShutdown() {
|
|||||||
Handler: srv,
|
Handler: srv,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
srv.SetupRoutes()
|
||||||
|
|
||||||
srv.log.Info(
|
srv.log.Info(
|
||||||
"http begin listen", "listenaddr", listenAddr,
|
"http begin listen", "listenaddr", listenAddr,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user