fspc / Yellow-Bike-Database

Yellow Bike Project Hours and Transaction Database for Community Bike Shops
GNU General Public License v3.0
7 stars 1 forks source link

Properly negotiate DHCP (IP change) so that shop stays open #86

Closed fspc closed 5 years ago

fspc commented 5 years ago

When YBDB is on a network where static ip is not assigned, and the ip changes, the shop closes. Either an option to turn off checks for IP, or a way to verify the connecting computer is on the same subnet would resolve this issue.

That should be easy, just add an option to check for a subnet, eg. 192.168.8.*, using a regexp.

Mayberrydeputy1 commented 5 years ago

Remove me from ur email list now Jonathan or I will be pressing charges for cyber harassment

Sent from my iPhone

On Feb 26, 2019, at 2:54 PM, Jonathan Rosenbaum notifications@github.com wrote:

When YBDB is on a network where static ip is not assigned, and the ip changes, the shop closes. Either an option to turn off checks for IP, or a way to verify the connecting computer is on the same subnet would resolve this issue.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

fspc commented 5 years ago

When the ip changed the first shop become the later shop, and the new shop became the earlier shop. Probably, not necessary to fix if above approach works. However, the key is finding the real ip being used since it is the public ip address.

One solution would be to provide an option to turn off this feature, since its real intent is to separate shops or activities that are operating in different locations, and that feature is not used that often.

The other solution would be to provide an option to allow a regexp. In this real example a Class B Network is involved so anyone in . would be able to interact with the live shop (after logging in) if a regexp was used for that part. On the other hand, other networks wouldn't be able to access the interface.

FIRST OPENED SHOP mysql> SELECT ip_address FROM shops WHERE shop_id=24; | ip_address | | ..1.2 |

SECOND OPENED SHOP mysql> SELECT ip_address FROM shops WHERE shop_id=23; | ip_address | | ..3.4 |

Both options could be provided, not ideal, but at least preventing the shop from inadvertently closing when a device (gateway) changes when it has a DHCP relationship to an external network.

A more sophisticated solution would be to limit the amount of devices that can connect to the regexp network or the application by keeping track of cookies or sessions. But then again, probably more than is really necessary.

The important function is current_shop_by_ip(), and the associated files it it running tests in.