-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update readme for country + ASN db support. Change flag to include country in the name * Support maxmind ASN DB * Update readme with ASN/MySQL Note * Store ASN data to mysql, if enabled
- Loading branch information
1 parent
72ca948
commit d1dcd7f
Showing
7 changed files
with
248 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package metrics | ||
|
||
// initTables ensures that the tables required exist and have the correct columns present | ||
func (m *Metrics) initTables() error { | ||
if m.mysqlClient == nil { | ||
return nil | ||
} | ||
query := "CREATE TABLE IF NOT EXISTS `asn` (" + | ||
" `asn` int unsigned NOT NULL," + | ||
" `organization` VARCHAR(255) NOT NULL," + | ||
" `count` int unsigned NOT NULL," + | ||
"UNIQUE KEY `asn-unique` (`asn`)" + | ||
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;" | ||
|
||
result, err := m.mysqlClient.Query(query) | ||
if err != nil { | ||
return err | ||
} | ||
return result.Close() | ||
} | ||
|
||
// DeleteASNRecords deletes all records from the asn table in the database | ||
func (m *Metrics) DeleteASNRecords() error { | ||
if m.mysqlClient == nil { | ||
return nil | ||
} | ||
query := "DELETE from asn;" | ||
result, err := m.mysqlClient.Query(query) | ||
if err != nil { | ||
return err | ||
} | ||
return result.Close() | ||
} |
Oops, something went wrong.