Răsfoiți Sursa

Fix INVALID_SNAC error in gaim when loading icon

To fix this error, this commit adds a separate BART server.
Mike 2 ani în urmă
părinte
comite
3efdf20c8f

+ 23 - 1
cmd/server/main.go

@@ -44,7 +44,7 @@ func main() {
 	adjListBuddyListStore := state.NewAdjListBuddyListStore()
 
 	wg := sync.WaitGroup{}
-	wg.Add(6)
+	wg.Add(7)
 
 	go func() {
 		http.StartManagementAPI(cfg, feedbagStore, sessionManager, logger)
@@ -149,6 +149,28 @@ func main() {
 		}.Start()
 		wg.Done()
 	}(logger)
+	go func(logger *slog.Logger) {
+		logger = logger.With("svc", "BART")
+		sessionManager := state.NewInMemorySessionManager(logger)
+		buddyService := foodgroup.NewBuddyService(sessionManager, feedbagStore, adjListBuddyListStore)
+		bartService := foodgroup.NewBARTService(logger, feedbagStore, buddyService)
+		authService := foodgroup.NewAuthService(cfg, sessionManager, feedbagStore, chatRegistry, adjListBuddyListStore, cookieBaker, buddyService)
+		oServiceService := foodgroup.NewOServiceServiceForBART(cfg, logger, buddyService)
+
+		oscar.BOSServer{
+			AuthService:   authService,
+			Config:        cfg,
+			CookieCracker: cookieBaker,
+			Handler: handler.NewBARTRouter(handler.Handlers{
+				BARTHandler:     handler.NewBARTHandler(logger, bartService),
+				OServiceHandler: handler.NewOServiceHandler(logger, oServiceService),
+			}),
+			ListenAddr:     net.JoinHostPort("", cfg.BARTPort),
+			Logger:         logger,
+			OnlineNotifier: oServiceService,
+		}.Start()
+		wg.Done()
+	}(logger)
 	go func(logger *slog.Logger) {
 		logger = logger.With("svc", "AUTH")
 		authHandler := foodgroup.NewAuthService(cfg, sessionManager, feedbagStore, chatRegistry, adjListBuddyListStore, cookieBaker, nil)

+ 1 - 0
config/config.go

@@ -7,6 +7,7 @@ type Config struct {
 	ApiPort     string `envconfig:"API_PORT" required:"true" val:"8080" description:"The port that the management API service binds to."`
 	AlertPort   string `envconfig:"ALERT_PORT" required:"true" val:"5194" description:"The port that the Alert service binds to."`
 	AuthPort    string `envconfig:"AUTH_PORT" required:"true" val:"5190" description:"The port that the auth service binds to."`
+	BARTPort    string `envconfig:"BART_PORT" required:"true" val:"5195" description:"The port that the BART service binds to."`
 	BOSPort     string `envconfig:"BOS_PORT" required:"true" val:"5191" description:"The port that the BOS service binds to."`
 	ChatNavPort string `envconfig:"CHAT_NAV_PORT" required:"true" val:"5193" description:"The port that the chat nav service binds to."`
 	ChatPort    string `envconfig:"CHAT_PORT" required:"true" val:"5192" description:"The port that the chat service binds to."`

+ 3 - 0
config/settings.bat

@@ -10,6 +10,9 @@ set ALERT_PORT=5194
 rem The port that the auth service binds to.
 set AUTH_PORT=5190
 
+rem The port that the BART service binds to.
+set BART_PORT=5195
+
 rem The port that the BOS service binds to.
 set BOS_PORT=5191
 

+ 3 - 0
config/settings.env

@@ -10,6 +10,9 @@ export ALERT_PORT=5194
 # The port that the auth service binds to.
 export AUTH_PORT=5190
 
+# The port that the BART service binds to.
+export BART_PORT=5195
+
 # The port that the BOS service binds to.
 export BOS_PORT=5191
 

+ 39 - 2
foodgroup/oservice.go

@@ -418,10 +418,10 @@ func (s OServiceService) SetUserInfoFields(ctx context.Context, sess *state.Sess
 			}
 		}
 		if status&wire.OServiceUserStatusDirectRequireAuth == wire.OServiceUserStatusDirectRequireAuth {
-			s.logger.InfoContext(ctx, "got unsupported status", "status", status)
+			s.logger.DebugContext(ctx, "got unsupported status", "status", status)
 		}
 		if status&wire.OServiceUserStatusHideIP == wire.OServiceUserStatusHideIP {
-			s.logger.InfoContext(ctx, "got unsupported status", "status", status)
+			s.logger.DebugContext(ctx, "got unsupported status", "status", status)
 		}
 	}
 	return wire.SNACMessage{
@@ -584,6 +584,29 @@ func (s OServiceServiceForBOS) ServiceRequest(ctx context.Context, sess *state.S
 				},
 			},
 		}, nil
+	case wire.BART:
+		cookie, err := s.cookieIssuer.Issue([]byte(sess.ScreenName()))
+		if err != nil {
+			return wire.SNACMessage{}, err
+		}
+		return wire.SNACMessage{
+			Frame: wire.SNACFrame{
+				FoodGroup: wire.OService,
+				SubGroup:  wire.OServiceServiceResponse,
+				RequestID: inFrame.RequestID,
+			},
+			Body: wire.SNAC_0x01_0x05_OServiceServiceResponse{
+				TLVRestBlock: wire.TLVRestBlock{
+					TLVList: wire.TLVList{
+						wire.NewTLV(wire.OServiceTLVTagsReconnectHere, net.JoinHostPort(s.cfg.OSCARHost, s.cfg.BARTPort)),
+						wire.NewTLV(wire.OServiceTLVTagsLoginCookie, cookie),
+						wire.NewTLV(wire.OServiceTLVTagsGroupID, wire.BART),
+						wire.NewTLV(wire.OServiceTLVTagsSSLCertName, ""),
+						wire.NewTLV(wire.OServiceTLVTagsSSLState, uint8(0x00)),
+					},
+				},
+			},
+		}, nil
 	case wire.ChatNav:
 		cookie, err := s.cookieIssuer.Issue([]byte(sess.ScreenName()))
 		if err != nil {
@@ -759,3 +782,17 @@ func NewOServiceServiceForAlert(cfg config.Config, logger *slog.Logger, buddyUpd
 		},
 	}
 }
+
+// NewOServiceServiceForBART creates a new instance of OServiceService for the
+// BART server.
+func NewOServiceServiceForBART(cfg config.Config, logger *slog.Logger, buddyUpdateBroadcaster BuddyBroadcaster) *OServiceService {
+	return &OServiceService{
+		buddyUpdateBroadcaster: buddyUpdateBroadcaster,
+		cfg:                    cfg,
+		logger:                 logger,
+		foodGroups: []uint16{
+			wire.BART,
+			wire.OService,
+		},
+	}
+}

+ 14 - 0
server/oscar/handler/routes.go

@@ -136,3 +136,17 @@ func NewAlertRouter(h Handlers) oscar.Router {
 
 	return router
 }
+
+func NewBARTRouter(h Handlers) oscar.Router {
+	router := oscar.NewRouter()
+
+	router.Register(wire.BART, wire.BARTUploadQuery, h.BARTHandler.UploadQuery)
+	router.Register(wire.BART, wire.BARTDownloadQuery, h.BARTHandler.DownloadQuery)
+
+	router.Register(wire.OService, wire.OServiceClientOnline, h.ClientOnline)
+	router.Register(wire.OService, wire.OServiceClientVersions, h.OServiceHandler.ClientVersions)
+	router.Register(wire.OService, wire.OServiceRateParamsQuery, h.OServiceHandler.RateParamsQuery)
+	router.Register(wire.OService, wire.OServiceRateParamsSubAdd, h.OServiceHandler.RateParamsSubAdd)
+
+	return router
+}