mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-01-18 18:56:24 +00:00
Avoid ICMP on connectivity check.
This commit is contained in:
parent
6c7f891a2a
commit
aa4ff76581
@ -10,6 +10,7 @@ module.exports = config =
|
||||
configMountPoint: process.env.CONFIG_MOUNT_POINT ? '/mnt/mmcblk0p1/config.json'
|
||||
ledFile: process.env.LED_FILE ? '/sys/class/leds/led0/brightness'
|
||||
successMessage: 'SUPERVISOR OK'
|
||||
heartbeatEndpoint: 'http://image.resin.io/ping'
|
||||
|
||||
config.remoteImage = config.registryEndpoint + '/' + config.localImage
|
||||
|
||||
|
@ -3,7 +3,7 @@ _ = require 'lodash'
|
||||
fs = Promise.promisifyAll require 'fs'
|
||||
config = require './config'
|
||||
mixpanel = require 'mixpanel'
|
||||
ping = require 'ping'
|
||||
request = Promise.promisifyAll require 'request'
|
||||
|
||||
# Parses package.json and returns resin-supervisor's version
|
||||
exports.getSupervisorVersion = ->
|
||||
@ -55,10 +55,13 @@ exports.blink = (ms = 200) ->
|
||||
.delay(ms)
|
||||
.then -> fs.writeFileAsync(config.ledFile, 0)
|
||||
|
||||
# Helps in checking connectivity by pinging the given site.
|
||||
exports.checkConnectivity = (host = '8.8.8.8') ->
|
||||
ping.sys.promise_probe(host,
|
||||
timeout: 1
|
||||
extra: [ '-c 1' ]
|
||||
).then (res) ->
|
||||
return res.alive
|
||||
# Helps in checking connectivity by pseudo-pinging our endpoint.
|
||||
exports.checkConnectivity = ->
|
||||
# We avoid using ICMP as this traffic is sometimes restricted/dropped. Good
|
||||
# ol' port 80 HTTP should always be available :-)
|
||||
request
|
||||
.getAsync(config.heartbeatEndpoint)
|
||||
.then ([ response ]) ->
|
||||
return response.statusCode in [ 200, 304 ]
|
||||
.catch ->
|
||||
return false
|
||||
|
Loading…
Reference in New Issue
Block a user