mirror of
https://wiilab.wiimart.org/wiimart/WiiSOAP
synced 2025-09-03 20:11:14 +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
|
.idea
|
||||||
config.xml
|
config.xml
|
||||||
WiiSOAP
|
WiiSOAP
|
||||||
|
tmp/
|
||||||
|
@ -20,4 +20,8 @@
|
|||||||
This is useful when testing CAS directly.
|
This is useful when testing CAS directly.
|
||||||
It is only functional when debug is enabled. -->
|
It is only functional when debug is enabled. -->
|
||||||
<NoAuth>false</NoAuth>
|
<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>
|
</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)
|
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,
|
// Since HTTP server runs on a separate Goroutine, this won't shut off the server,
|
||||||
// rather kill communication with the requesting console
|
// rather kill communication with the requesting console
|
||||||
panic(err)
|
panic(err)
|
||||||
@ -167,7 +167,7 @@ func register(e *Envelope) {
|
|||||||
return
|
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,
|
// Since HTTP server runs on a separate Goroutine, this won't shut off the server,
|
||||||
// rather kill communication with the requesting console
|
// rather kill communication with the requesting console
|
||||||
panic(err)
|
panic(err)
|
||||||
|
3
main.go
3
main.go
@ -42,6 +42,7 @@ var pool *pgxpool.Pool
|
|||||||
var ctx = context.Background()
|
var ctx = context.Background()
|
||||||
var isDebug = false
|
var isDebug = false
|
||||||
var ignoreAuth = false
|
var ignoreAuth = false
|
||||||
|
var whitelistEnabled = false
|
||||||
|
|
||||||
// checkError makes error handling not as ugly and inefficient.
|
// checkError makes error handling not as ugly and inefficient.
|
||||||
func checkError(err error) {
|
func checkError(err error) {
|
||||||
@ -72,6 +73,8 @@ func main() {
|
|||||||
ignoreAuth = readConfig.NoAuth
|
ignoreAuth = readConfig.NoAuth
|
||||||
}
|
}
|
||||||
|
|
||||||
|
whitelistEnabled = readConfig.Whitelist
|
||||||
|
|
||||||
// Start SQL.
|
// Start SQL.
|
||||||
dbString := fmt.Sprintf("postgres://%s:%s@%s/%s", readConfig.SQLUser, readConfig.SQLPass, readConfig.SQLAddress, readConfig.SQLDB)
|
dbString := fmt.Sprintf("postgres://%s:%s@%s/%s", readConfig.SQLUser, readConfig.SQLPass, readConfig.SQLAddress, readConfig.SQLDB)
|
||||||
dbConf, err := pgxpool.ParseConfig(dbString)
|
dbConf, err := pgxpool.ParseConfig(dbString)
|
||||||
|
@ -39,8 +39,9 @@ type Config struct {
|
|||||||
SQLPass string `xml:"SQLPass"`
|
SQLPass string `xml:"SQLPass"`
|
||||||
SQLDB string `xml:"SQLDB"`
|
SQLDB string `xml:"SQLDB"`
|
||||||
|
|
||||||
Debug bool `xml:"Debug"`
|
Debug bool `xml:"Debug"`
|
||||||
NoAuth bool `xml:"NoAuth"`
|
NoAuth bool `xml:"NoAuth"`
|
||||||
|
Whitelist bool `xml:"Whitelist"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Envelope represents the root element of any response, soapenv:Envelope.
|
// Envelope represents the root element of any response, soapenv:Envelope.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user