| 1 | #include <Poco/Net/DNS.h> |
|---|---|
| 2 | #include <Common/getFQDNOrHostName.h> |
| 3 | |
| 4 | |
| 5 | namespace |
| 6 | { |
| 7 | std::string getFQDNOrHostNameImpl() |
| 8 | { |
| 9 | try |
| 10 | { |
| 11 | return Poco::Net::DNS::thisHost().name(); |
| 12 | } |
| 13 | catch (...) |
| 14 | { |
| 15 | return Poco::Net::DNS::hostName(); |
| 16 | } |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | |
| 21 | const std::string & getFQDNOrHostName() |
| 22 | { |
| 23 | static std::string result = getFQDNOrHostNameImpl(); |
| 24 | return result; |
| 25 | } |
| 26 |