Skip to content

Commit

Permalink
finish issues with JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
grantshandy committed Dec 19, 2020
1 parent ba89515 commit 2d134ce
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<h1 align="center">ipmap</h1>

<p align="center">
An interactive map that shows connected IP addresses.
<img src=data/screenshot.png>
</p>
<p align="center">An interactive map that shows connected IP addresses.</p>
<hr>
<p align="center"><img src=data/screenshot.png></p>

## Requirements
ipmap uses `libpcap-dev`, which is only easily available on UNIX-like systems (Linux, MacOS, *BSD).
Expand Down Expand Up @@ -49,8 +48,8 @@ If no service specified, ipapi will be used, which will limit how many IP is det

## Command Line Options
```
ipmap 0.1.2
Skyline High School Coding Club Authors <[email protected]>
ipmap 0.1.5
Skyline High Coding Club Authors
USAGE:
ipmap [FLAGS] [OPTIONS]
Expand All @@ -61,5 +60,7 @@ FLAGS:
-V, --version Prints version information
OPTIONS:
-s, --service <SERVICE> Geolocation API
-p, --port <PORT> Set webserver port, default port 700
-s, --service <SERVICE> Choose Geolocation API [possible values: ipwhois, ipapi, ipapico, freegeoip]
-w, --write-to-file <PATH> Set path to write JSON to
```
4 changes: 2 additions & 2 deletions data/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var alreadyAdded = new Set();

function addMarkers(jsonText) {
console.log(jsonText)
for(var i = 1; i < jsonText.length; i++) {
for(var i = 0; i < jsonText.length; i++) {
var obj = jsonText[i];

if (alreadyAdded.has(obj.ip)) {
Expand All @@ -17,7 +17,7 @@ function addMarkers(jsonText) {

console.log(obj.ip);

document.getElementById("totalIps").innerHTML = jsonText.length - 1 + " Unique IP's";
document.getElementById("totalIps").innerHTML = jsonText.length + " Unique IP's";

L.marker([obj.latitude, obj.longitude]).addTo(ipmap)
// .bindpopup(obj.ip);
Expand Down
6 changes: 5 additions & 1 deletion src/ip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,11 @@ pub fn get_document() -> String {

json.push_str("[\n");

for a in &*IP_MAP.read().unwrap() {
let v = &*IP_MAP.read().unwrap();

let iter = v[1..].iter();

for a in iter {
let address = IPAddress {
ip: a[0].to_owned(),
latitude: a[1].to_owned(),
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fn main() {
Arg::with_name("port")
.long("port")
.short("p")
.help("Set webserver port, default port 700")
.help("Set webserver port, if not set it defaults to port 700")
.required(false)
.takes_value(true)
.value_name("PORT"),
Expand Down
3 changes: 3 additions & 0 deletions test
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[
{"ip":"193.148.18.75","latitude":"40.7157","longitude":"-74"}
]

0 comments on commit 2d134ce

Please sign in to comment.