-
Notifications
You must be signed in to change notification settings - Fork 3
✨ fix: include eeid & improve misc settings dump #2303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,16 +30,25 @@ type eiData struct { | |
| var ( | ||
| // Contracts is a map of contracts and is saved to disk | ||
| eiDatas map[string]*eiData | ||
|
|
||
| // CoopStatusFixEnabled is a callback set from outside the ei package (to avoid import | ||
| // cycles) that returns true when the alternate coop_status endpoint and eeid override | ||
| // should be used. It is wired up in main. | ||
| CoopStatusFixEnabled func() bool | ||
| ) | ||
|
|
||
| func init() { | ||
| eiDatas = make(map[string]*eiData) | ||
| } | ||
|
|
||
| // GetCoopStatus retrieves the coop status for a given contract and coop | ||
| func GetCoopStatus(contractID string, coopID string) (*ContractCoopStatusResponse, time.Time, string, error) { | ||
| func GetCoopStatus(contractID string, coopID string, eeidOverride string) (*ContractCoopStatusResponse, time.Time, string, error) { | ||
| eggIncID := config.EIUserIDBasic | ||
| reqURL := "https://www.auxbrain.com/ei/coop_status_bot" | ||
| if eeidOverride != "" && CoopStatusFixEnabled != nil && CoopStatusFixEnabled() { | ||
| eggIncID = DecryptEID(eeidOverride) | ||
| reqURL = "https://www.auxbrain.com/ei/coop_status" | ||
| } | ||
|
Comment on lines
+48
to
+51
|
||
| enc := base64.StdEncoding | ||
| timestamp := time.Now() | ||
|
|
||
|
|
@@ -205,9 +214,13 @@ func ClearCoopStatusCachedData() { | |
|
|
||
| // GetCoopStatusForCompletedContracts retrieves the coop status for a given contract and coop, but is intended for completed contracts | ||
| // This saves the data in compressed form without a timestamp in the filename | ||
| func GetCoopStatusForCompletedContracts(contractID string, coopID string) (*ContractCoopStatusResponse, time.Time, string, error) { | ||
| func GetCoopStatusForCompletedContracts(contractID string, coopID string, eeidOverride string) (*ContractCoopStatusResponse, time.Time, string, error) { | ||
| eggIncID := config.EIUserIDBasic | ||
| reqURL := "https://www.auxbrain.com/ei/coop_status_bot" | ||
| if eeidOverride != "" && CoopStatusFixEnabled != nil && CoopStatusFixEnabled() { | ||
| eggIncID = DecryptEID(eeidOverride) | ||
| reqURL = "https://www.auxbrain.com/ei/coop_status" | ||
| } | ||
|
Comment on lines
+217
to
+223
|
||
| enc := base64.StdEncoding | ||
| timestamp := time.Now() | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When eeidOverride is provided and the fix is enabled, this switches to the user-authenticated coop_status endpoint but still uses the same in-memory cache key / file cache scheme (keyed only by contractID+coopID later in the function). That can let a response fetched with one user’s Egg Inc ID be served from cache to other callers (or to callers using the bot endpoint), effectively bypassing the endpoint’s authorization. Consider either including the effective Egg Inc ID + endpoint in the cache key / filename, or disabling cache reads/writes when using eeidOverride.