diff options
| author | Cristian Maglie <c.maglie@bug.st> | 2013-07-01 19:09:43 +0200 | 
|---|---|---|
| committer | Cristian Maglie <c.maglie@bug.st> | 2013-07-01 19:12:49 +0200 | 
| commit | ef0f1e593f7af6463642154ec1eb675e1231cb45 (patch) | |
| tree | 1956be57b42219da85a63e6e1e1141c28b9e73b2 /libraries/Bridge/YunServer.cpp | |
| parent | a22033dd5d1b867def45b80d607592bf76cde052 (diff) | |
YunServer: added method to allow listening on localhost only
Diffstat (limited to 'libraries/Bridge/YunServer.cpp')
| -rw-r--r-- | libraries/Bridge/YunServer.cpp | 7 | 
1 files changed, 5 insertions, 2 deletions
| diff --git a/libraries/Bridge/YunServer.cpp b/libraries/Bridge/YunServer.cpp index c6d54e4..c0ed88c 100644 --- a/libraries/Bridge/YunServer.cpp +++ b/libraries/Bridge/YunServer.cpp @@ -19,7 +19,7 @@  #include <YunServer.h>  YunServer::YunServer(uint16_t _p, BridgeClass &_b) : -  bridge(_b), port(_p), listening(false) { +  bridge(_b), port(_p), listening(false), useLocalhost(false) {  }  void YunServer::begin() { @@ -29,7 +29,10 @@ void YunServer::begin() {      port & 0xFF    };    uint8_t res[1]; -  bridge.transfer(tmp, 3, (const uint8_t *)"0.0.0.0", 7, res, 1); +  String address = F("127.0.0.1"); +  if (!useLocalhost) +    address = F("0.0.0.0"); +  bridge.transfer(tmp, 3, (const uint8_t *)address.c_str(), address.length(), res, 1);    listening = (res[0] == 1);  } | 
