mirror of
https://wiilab.wiimart.org/wiimart/WiiSOAP
synced 2025-09-02 19:41:08 +02:00
Allow toggling whitelist
This commit is contained in:
parent
2b37235666
commit
2ece89662a
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
.idea
|
||||
config.xml
|
||||
WiiSOAP
|
||||
tmp/
|
||||
|
@ -20,4 +20,8 @@
|
||||
This is useful when testing CAS directly.
|
||||
It is only functional when debug is enabled. -->
|
||||
<NoAuth>false</NoAuth>
|
||||
<!-- Set to true to enable serial number
|
||||
whitelisting by reading a newline separated file
|
||||
located at whitelist.txt. -->
|
||||
<Whitelist>false</Whitelist>
|
||||
</Config>
|
||||
|
4
ias.go
4
ias.go
@ -130,7 +130,7 @@ func syncRegistration(e *Envelope) {
|
||||
e.Error(7, "An error occurred querying the database.", err)
|
||||
}
|
||||
|
||||
if !slices.Contains(getWhitelistedSerialNumbers(), serialNumber) {
|
||||
if whitelistEnabled && !slices.Contains(getWhitelistedSerialNumbers(), serialNumber) {
|
||||
// Since HTTP server runs on a separate Goroutine, this won't shut off the server,
|
||||
// rather kill communication with the requesting console
|
||||
panic(err)
|
||||
@ -167,7 +167,7 @@ func register(e *Envelope) {
|
||||
return
|
||||
}
|
||||
|
||||
if !slices.Contains(getWhitelistedSerialNumbers(), serialNo) {
|
||||
if whitelistEnabled && !slices.Contains(getWhitelistedSerialNumbers(), serialNo) {
|
||||
// Since HTTP server runs on a separate Goroutine, this won't shut off the server,
|
||||
// rather kill communication with the requesting console
|
||||
panic(err)
|
||||
|
3
main.go
3
main.go
@ -42,6 +42,7 @@ var pool *pgxpool.Pool
|
||||
var ctx = context.Background()
|
||||
var isDebug = false
|
||||
var ignoreAuth = false
|
||||
var whitelistEnabled = false
|
||||
|
||||
// checkError makes error handling not as ugly and inefficient.
|
||||
func checkError(err error) {
|
||||
@ -72,6 +73,8 @@ func main() {
|
||||
ignoreAuth = readConfig.NoAuth
|
||||
}
|
||||
|
||||
whitelistEnabled = readConfig.Whitelist
|
||||
|
||||
// Start SQL.
|
||||
dbString := fmt.Sprintf("postgres://%s:%s@%s/%s", readConfig.SQLUser, readConfig.SQLPass, readConfig.SQLAddress, readConfig.SQLDB)
|
||||
dbConf, err := pgxpool.ParseConfig(dbString)
|
||||
|
@ -39,8 +39,9 @@ type Config struct {
|
||||
SQLPass string `xml:"SQLPass"`
|
||||
SQLDB string `xml:"SQLDB"`
|
||||
|
||||
Debug bool `xml:"Debug"`
|
||||
NoAuth bool `xml:"NoAuth"`
|
||||
Debug bool `xml:"Debug"`
|
||||
NoAuth bool `xml:"NoAuth"`
|
||||
Whitelist bool `xml:"Whitelist"`
|
||||
}
|
||||
|
||||
// Envelope represents the root element of any response, soapenv:Envelope.
|
||||
|
Loading…
x
Reference in New Issue
Block a user