oxen-io / loki-launcher

Manages the Loki Storage Server, Loki Daemon and Lokinet simultaneously
MIT License
16 stars 10 forks source link

Refactor getPublicIPv4 #28

Closed BeaudanBrown closed 4 years ago

BeaudanBrown commented 5 years ago

For review at Ryan's leisure

Simplifying getPublicIPv4 with modern JS Previous implementation could potentially return empty string as a "successful" result if both requests return undefined Also the same service could be used twice if the first attempt returns false for one of the calls

With this refactor getIP() will remove elements from the services list and try to get the ip from them until there are no elements left, resolving with either an IP string or false If the results are different or both false, retries counter is incremented and the process is repeated

The getPublicIPv4 function is async which means that it returns a promise, and ideally this promise would just resolve with the result, but for sake of consistency with the previous implementation I left the callback argument and simply ignore the promise (but keeping the async keyword so that I can await inside the function)

neuroscr commented 4 years ago

superseded by #65