Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IP field to the Add a Sensor page #732

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion server/mhn/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ def create_sensor():
else:
sensor = Sensor(**request.json)
sensor.uuid = str(uuid1())
sensor.ip = request.remote_addr
try:
if request.json['ip'] == "":
sensor.ip = request.remote_addr
except KeyError:
sensor.ip = request.remote_addr
Clio().authkey.new(**sensor.new_auth_dict()).post()
try:
db.session.add(sensor)
Expand Down
5 changes: 3 additions & 2 deletions server/mhn/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ $(document).ready(function() {
var sensorObj = {
name: $('#name').val(),
hostname: $('#hostname').val(),
honeypot: $('#honeypot').val()
honeypot: $('#honeypot').val(),
ip: $('#ip').val()
};

$('#alert-row').hide();
Expand Down Expand Up @@ -385,7 +386,7 @@ $(document).ready(function() {
$('#error-txt').html(resp.responseJSON.error);
$('#msg-container').show();
}
});
});
} else {
$('#alert-text').removeClass('success').addClass('warning');
$('#error-txt').html('Not a valid email address');
Expand Down
10 changes: 8 additions & 2 deletions server/mhn/templates/ui/add-sensor.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ <h2>Add a Sensor</h2>
<div class="small-3 columns">
<label>Hostname</label>
</div>
<div class="small-3 pull-3 columns">
<div class="small-3 columns">
<label>Honeypot</label>
</div>
<div class="small-3 columns">
<label>IP (optional)</label>
</div>
</div>
<div class="row">
<input id="_csrf_token" name="_csrf_token" type="hidden" value="{{ csrf_token() }}">
Expand All @@ -29,7 +32,10 @@ <h2>Add a Sensor</h2>
<div class="small-3 columns">
<input id="honeypot" type="text" name="honeypot" />
</div>
<div class="small-6 columns">
<div class="small-3 columns">
<input id="ip" type="text" name="ip" />
</div>
<div class="small-3 columns">
<input id="create-btn" class="tiny button" type="submit" value="CREATE" />
</div>
</div>
Expand Down