diff --git a/config/config.go b/config/config.go index 25794063..7eb60c09 100644 --- a/config/config.go +++ b/config/config.go @@ -14,7 +14,6 @@ type Config struct { ODirPort string `envconfig:"ODIR_PORT" required:"true" val:"5197" description:"The port that the ODir service binds to."` DBPath string `envconfig:"DB_PATH" required:"true" val:"oscar.sqlite" description:"The path to the SQLite database file. The file and DB schema are auto-created if they doesn't exist."` DisableAuth bool `envconfig:"DISABLE_AUTH" required:"true" val:"true" description:"Disable password check and auto-create new users at login time. Useful for quickly creating new accounts during development without having to register new users via the management API."` - FailFast bool `envconfig:"FAIL_FAST" required:"true" val:"false" description:"Crash the server in case it encounters a client message type it doesn't recognize. This makes failures obvious for debugging purposes."` LogLevel string `envconfig:"LOG_LEVEL" required:"true" val:"info" description:"Set logging granularity. Possible values: 'trace', 'debug', 'info', 'warn', 'error'."` OSCARHost string `envconfig:"OSCAR_HOST" required:"true" val:"127.0.0.1" description:"The hostname that AIM clients connect to in order to reach OSCAR services (auth, BOS, BUCP, etc). Make sure the hostname is reachable by all clients. For local development, the default loopback address should work provided the server and AIM client(s) are running on the same machine. For LAN-only clients, a private IP address (e.g. 192.168..) or hostname should suffice. For clients connecting over the Internet, specify your public IP address and ensure that TCP ports 5190-5197 are open on your firewall."` } diff --git a/config/ras.service b/config/ras.service index ddd73b13..b2756ce2 100644 --- a/config/ras.service +++ b/config/ras.service @@ -16,6 +16,7 @@ Environment="DB_PATH=/var/ras/oscar.sqlite" Environment="DISABLE_AUTH=true" Environment="FAIL_FAST=false" Environment="LOG_LEVEL=info" +Environment="ODIR_PORT=5197" Environment="OSCAR_HOST=127.0.0.1" ExecStart=/opt/ras/retro_aim_server Restart=on-failure diff --git a/config/settings.env b/config/settings.env index c7a61897..bb58d875 100644 --- a/config/settings.env +++ b/config/settings.env @@ -37,10 +37,6 @@ export DB_PATH=oscar.sqlite # new users via the management API. export DISABLE_AUTH=true -# Crash the server in case it encounters a client message type it doesn't -# recognize. This makes failures obvious for debugging purposes. -export FAIL_FAST=false - # Set logging granularity. Possible values: 'trace', 'debug', 'info', 'warn', # 'error'. export LOG_LEVEL=info diff --git a/server/oscar/admin.go b/server/oscar/admin.go index 8f6e8c3f..070e1f65 100644 --- a/server/oscar/admin.go +++ b/server/oscar/admin.go @@ -102,10 +102,10 @@ func (rt AdminServer) handleNewConnection(ctx context.Context, rwc io.ReadWriteC return err } - return dispatchIncomingMessagesSimple(ctx, sess, flapc, rwc, rt.Logger, rt.Handler, rt.Config) + return dispatchIncomingMessagesSimple(ctx, sess, flapc, rwc, rt.Logger, rt.Handler) } -func dispatchIncomingMessagesSimple(ctx context.Context, sess *state.Session, flapc *wire.FlapClient, r io.Reader, logger *slog.Logger, router Handler, config config.Config) error { +func dispatchIncomingMessagesSimple(ctx context.Context, sess *state.Session, flapc *wire.FlapClient, r io.Reader, logger *slog.Logger, router Handler) error { defer func() { logger.InfoContext(ctx, "user disconnected") }() @@ -151,9 +151,6 @@ func dispatchIncomingMessagesSimple(ctx context.Context, sess *state.Session, fl if err1 := sendInvalidSNACErr(inFrame, flapc); err1 != nil { return errors.Join(err1, err) } - if config.FailFast { - panic(err.Error()) - } break } return err diff --git a/server/oscar/bos.go b/server/oscar/bos.go index 5e87fd77..09573f0c 100644 --- a/server/oscar/bos.go +++ b/server/oscar/bos.go @@ -113,5 +113,5 @@ func (rt BOSServer) handleNewConnection(ctx context.Context, rwc io.ReadWriteClo return err } - return dispatchIncomingMessages(ctx, sess, flapc, rwc, rt.Logger, rt.Handler, rt.Config) + return dispatchIncomingMessages(ctx, sess, flapc, rwc, rt.Logger, rt.Handler) } diff --git a/server/oscar/chat.go b/server/oscar/chat.go index 9fc17eac..641721dc 100644 --- a/server/oscar/chat.go +++ b/server/oscar/chat.go @@ -101,5 +101,5 @@ func (rt ChatServer) handleNewConnection(ctx context.Context, rwc io.ReadWriteCl } ctx = context.WithValue(ctx, "screenName", chatSess.IdentScreenName()) - return dispatchIncomingMessages(ctx, chatSess, flapc, rwc, rt.Logger, rt.Handler, rt.Config) + return dispatchIncomingMessages(ctx, chatSess, flapc, rwc, rt.Logger, rt.Handler) } diff --git a/server/oscar/connection.go b/server/oscar/connection.go index 3929c69d..8d6cfa57 100644 --- a/server/oscar/connection.go +++ b/server/oscar/connection.go @@ -8,7 +8,6 @@ import ( "io" "log/slog" - "github.com/mk6i/retro-aim-server/config" "github.com/mk6i/retro-aim-server/server/oscar/middleware" "github.com/mk6i/retro-aim-server/state" "github.com/mk6i/retro-aim-server/wire" @@ -34,7 +33,7 @@ func sendInvalidSNACErr(frameIn wire.SNACFrame, rw ResponseWriter) error { // or when the session closes. // // todo: this method has too many params and should be folded into a new type -func dispatchIncomingMessages(ctx context.Context, sess *state.Session, flapc *wire.FlapClient, r io.Reader, logger *slog.Logger, router Handler, config config.Config) error { +func dispatchIncomingMessages(ctx context.Context, sess *state.Session, flapc *wire.FlapClient, r io.Reader, logger *slog.Logger, router Handler) error { defer func() { logger.InfoContext(ctx, "user disconnected") }() @@ -80,9 +79,6 @@ func dispatchIncomingMessages(ctx context.Context, sess *state.Session, flapc *w if err1 := sendInvalidSNACErr(inFrame, flapc); err1 != nil { return errors.Join(err1, err) } - if config.FailFast { - panic(err.Error()) - } break } return err @@ -107,10 +103,10 @@ func dispatchIncomingMessages(ctx context.Context, sess *state.Session, flapc *w } middleware.LogRequest(ctx, logger, m.Frame, m.Body) case <-sess.Closed(): - // disconnect with error code that indicates user was kicked off by - // another sign on event block := wire.TLVRestBlock{} + // error code indicating user signed in a different location block.Append(wire.NewTLVBE(0x0009, uint8(0x01))) + // "more info" button block.Append(wire.NewTLVBE(0x000b, "https://github.com/mk6i/retro-aim-server")) if err := flapc.SendSignoffFrame(block); err != nil { return fmt.Errorf("unable to gracefully disconnect user. %w", err) diff --git a/server/oscar/connection_test.go b/server/oscar/connection_test.go index 85cd68c6..ae94fed3 100644 --- a/server/oscar/connection_test.go +++ b/server/oscar/connection_test.go @@ -11,7 +11,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - "github.com/mk6i/retro-aim-server/config" "github.com/mk6i/retro-aim-server/state" "github.com/mk6i/retro-aim-server/wire" ) @@ -26,7 +25,7 @@ func TestHandleChatConnection_MessageRelay(t *testing.T) { clientReader, serverWriter := io.Pipe() go func() { flapc := wire.NewFlapClient(0, nil, serverWriter) - err := dispatchIncomingMessages(context.Background(), sess, flapc, serverReader, slog.Default(), nil, config.Config{}) + err := dispatchIncomingMessages(context.Background(), sess, flapc, serverReader, slog.Default(), nil) assert.NoError(t, err) }() @@ -145,7 +144,7 @@ func TestHandleChatConnection_ClientRequest(t *testing.T) { clientReader, serverWriter := io.Pipe() go func() { flapc := wire.NewFlapClient(0, nil, serverWriter) - assert.NoError(t, dispatchIncomingMessages(context.Background(), sess, flapc, serverReader, slog.Default(), router, config.Config{})) + assert.NoError(t, dispatchIncomingMessages(context.Background(), sess, flapc, serverReader, slog.Default(), router)) }() // send client messages