-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 14e2aba
Showing
8 changed files
with
156 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
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 @@ | ||
/Release/* |
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,42 @@ | ||
@echo off | ||
|
||
if not exist "Release" md "Release" | ||
|
||
set APP=oui_standardize | ||
|
||
set GOARCH=amd64 | ||
call :Build_OS | ||
|
||
set GOARCH=386 | ||
call :Build_OS | ||
|
||
pause | ||
exit /b | ||
|
||
:Build_OS | ||
|
||
set GOOS=windows | ||
set EXT=.exe | ||
set INC=include_windows.go | ||
call :Build | ||
|
||
set GOOS=linux | ||
set EXT= | ||
set INC=include_other.go | ||
call :Build | ||
|
||
if %GOARCH% == 386 exit /b | ||
|
||
set GOOS=darwin | ||
set EXT=.app | ||
set INC=include_other.go | ||
call :Build | ||
|
||
exit /b | ||
|
||
:Build | ||
|
||
echo Building %APP%_%GOOS%_%GOARCH%%EXT%... | ||
go build -ldflags="-s -w" -o "Release/%APP%_%GOOS%_%GOARCH%%EXT%" %APP%.go %INC% | ||
|
||
exit /b |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 ScriptTiger | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,15 @@ | ||
[![Say Thanks!](https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg)](https://saythanks.io/to/thescripttiger%40gmail.com) | ||
|
||
# oui_standardize | ||
oui_standardize standardizes IEEE MAC address block files (CSV files) containing OUI records by importing an arbitrary number of said files, sorting them by MAC address prefix, and then outputting the results to standard output (stdout). Curly brackets are used as delimiters and multi-line fields are reduced to single lines in order to allow scripts to more easily parse the records with as little overhead as possible. | ||
|
||
Usage: `oui_standardize [<file>] [<file>] [<file>]...` | ||
|
||
# More About ScriptTiger | ||
|
||
For more ScriptTiger scripts and goodies, check out ScriptTiger's GitHub Pages website: | ||
https://scripttiger.github.io/ | ||
|
||
[![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MZ4FH4G5XHGZ4) | ||
|
||
Donate Monero (XMR): 441LBeQpcSbC1kgangHYkW8Tzo8cunWvtVK4M6QYMcAjdkMmfwe8XzDJr1c4kbLLn3NuZKxzpLTVsgFd7Jh28qipR5rXAjx |
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,4 @@ | ||
package main | ||
|
||
//Set line endings to LF | ||
const eol = "\n" |
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,4 @@ | ||
package main | ||
|
||
//Set line endings to CRLF | ||
const eol = "\r\n" |
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,67 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
"io" | ||
"encoding/csv" | ||
"strings" | ||
"sort" | ||
) | ||
|
||
var data []string | ||
|
||
func readCSV(file string) { | ||
|
||
raw, err := os.Open(file) | ||
if err != nil {panic(err)} | ||
defer raw.Close() | ||
|
||
reader := csv.NewReader(raw) | ||
|
||
// Skip header line | ||
reader.Read() | ||
|
||
for { | ||
// Read CSV line | ||
line, err := reader.Read() | ||
|
||
// Validate line | ||
if err == io.EOF {break} | ||
if err != nil {panic(err)} | ||
|
||
// Remove multi-line strings from addresses | ||
line[3] = strings.Replace(line[3], "\r", "", -1) | ||
line[3] = strings.Replace(line[3], "\n", " ", -1) | ||
|
||
// Null-separated strings, starting with mac prefix | ||
data = append(data, strings.Join([]string{line[1], line[0], line[2], line[3]}, "\x00")) | ||
} | ||
|
||
} | ||
|
||
func help() { | ||
|
||
os.Stdout.WriteString("Usage: oui_standardize [<file>] [<file>] [<file>]...\n") | ||
os.Exit(0) | ||
|
||
} | ||
|
||
func main() { | ||
|
||
//Display help and exit if not enough arguments | ||
if len(os.Args) < 2 {help()} | ||
|
||
// Treat arguments as file paths and read all files into data | ||
for i := 1; i < len(os.Args); i++ {readCSV(os.Args[i])} | ||
|
||
// Sort data | ||
sort.Strings(data) | ||
|
||
// Format and output | ||
for _, line := range data { | ||
fields := strings.Split(line, "\x00") | ||
os.Stdout.WriteString( | ||
"{"+fields[1]+"}{"+fields[0]+"}{"+fields[2]+"}{"+fields[3]+"}"+eol) | ||
} | ||
|
||
} |