forked from fw42/honeymap
-
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.
Both Socket.io feeds working in CoffeeScript
- Loading branch information
Showing
12 changed files
with
213 additions
and
108 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
class Feed | ||
constructor: (map, log) -> | ||
@map = map | ||
@log = log | ||
@socket = io.connect('/'); | ||
@socket.on("marker", @handler) | ||
|
||
handler: (data) => | ||
lat1 = data.latitude | ||
lng1 = data.longitude | ||
return unless lat1 and lng1 | ||
src = new Marker(@map, lat1, lng1, data.type, "src", data.countrycode, data.city) | ||
return if src.x == 0 and src.y == 0 | ||
lat2 = data.latitude2 | ||
lng2 = data.longitude2 | ||
if lat2 and lng2 | ||
dst = new Marker(@map, lat2, lng2, data.type, "dst", data.countrycode2, data.city2) | ||
if dst.x == 0 and dst.y == 0 then dst = null | ||
@addLog(src, dst, data.md5) | ||
@map.addMarker(src) | ||
@map.addMarker(dst) if dst | ||
|
||
addLog: (src, dst, md5) -> | ||
return unless src.regionName() | ||
timestamp = new Date().toTimeString().substring(0,8) | ||
attacktype = if src.eventName == "thug.events" then "scan" else "attack" | ||
logstr = """ | ||
<div class="log_timestamp">#{timestamp}</div> | ||
<div class="log_bracket"><</div>#{src.eventName}<div class="log_bracket">></div> | ||
New #{attacktype} from <div class="log_country">#{src.location()}</div> | ||
<small>#{src.name()}</small> | ||
""" | ||
if dst and dst.regionName() | ||
logstr += " to <div class=\"log_country\">#{dst.location()}</div> <small>#{dst.name()}</small>" | ||
if md5 | ||
logstr += " <div class=\"log_bracket2\">[</div>" + \ | ||
"<div class=\"log_info\"><a href=\"http://www.virustotal.com/search/?query=#{md5}\">#{md5.substr(0,9)}</a></div>" + \ | ||
"<div class=\"log_bracket2\">]</div>" | ||
@log.add logstr |
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,14 @@ | ||
class Feed | ||
constructor: (map, log) -> | ||
@map = map | ||
@log = log | ||
@socket = io.connect('/') | ||
@socket.on("marker", @handler) | ||
|
||
handler: (data) => | ||
lat = data.lat | ||
lng = data.lng | ||
marker = new Marker(@map, lat, lng, "socketio_random") | ||
return unless marker.regionCode | ||
@map.addMarker(marker) | ||
@log.add "New event in " + marker.regionName() + " " + marker.name() |
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
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
Oops, something went wrong.