k4yt3x / wg-meshconf

WireGuard full mesh configuration generator.
GNU General Public License v3.0
938 stars 105 forks source link

Adding new Hosts via Excel not working #24

Closed multimill closed 3 years ago

multimill commented 3 years ago

Hello,

I tried to add new hosts after some time and the program fails everytime with error "The value of Address cannot be automatically generated".

Steps to reproduce:

  1. Create .csv file via "wg-meshconf init"
  2. Open .csv file and add hosts
  3. Use command "wg-meshconf init" -> everything works fine and missing data is added automatically
  4. Open .csv file with Excel again and add a new host with only Name, Address and Endpoint and save it
  5. Use command "wg-meshconf init" -> Error message "The value of Address cannot be automatically generated" appears.

Is there any workaround for this except adding all hosts at the beginning?

Thanks

k4yt3x commented 3 years ago

wg-meshconf was designed to accept new hosts at any point. If you encountered this issue as described, then you've either found a bug or didn't do it right. I didn't manage to reproduce this error at my end.

I took my test file and added a new line:

image

Then I ran init again:

image

Everything works as expected. Judging by the error message you're getting, are you sure you filled in Address correctly and saved it to file?

multimill commented 3 years ago

I just tried again and I do have the same problem again. I am using the latest version of wg-meshconf on a Win10 machine. Running in normal cmd window.

I cannot upload .csv files here but I zipped them and uploaded them.

examples.zip

So, the v1 is the file I get when I create a new .csv file via "wg-meshconf init" and put in 2 new lines with two servers. After running "wg-meshconf init" again I get the v2. So I do paste the new Server3 below the new created lines and save it like the v3 file. When I try to run the init command again I do get the given error.

Hope this helps to show my problem. Maybe I am missing something or enter the wrong values?!

EDIT: Okay, my problem is that in my config there is always an empty line created between the ones with vaules. This does actually break it. Maybe this does only happen on Windows 10? I am running Python 3.9 64 Bit if this matters.

k4yt3x commented 3 years ago

Okay, my problem is that in my config there is always an empty line created between the ones with vaules.

I see that in your CSV file. To wg-meshconf, it's a peer with all fields left empty.

Maybe this does only happen on Windows 10?

I'm not sure if it's editor-specific. What editor are you using? Excel?

multimill commented 3 years ago

I'm not sure if it's editor-specific. What editor are you using? Excel?

I tried with different editors. First I used Excel but same does happen in LibreOffice Calc, Notepad++ or the normal notepad.exe from Windows. I just tried the same file on the Windows and Ubuntu machine (like the v1 I uploaded earlier) and on Ubuntu everything is fine while on Windows the empty lines are created.

Guess I will just stick with using it on Ubuntu and mount the .csv file on Windows to edit them.

k4yt3x commented 3 years ago

I think I know what's going on: https://stackoverflow.com/questions/3348460/csv-file-written-with-python-has-blank-lines-between-each-row

multimill commented 3 years ago

Yes, this does look like my problem. But I don't have any clue how to implement a fix.

k4yt3x commented 3 years ago

Here's a quick & dirty way:

wg-meshconf.zip

This is a version in development. You'll need to do pip install --user rich before you can use it since this dependency is not included in the current release of wg-meshconf. Open a terminal and cd into the decompressed wg-meshconf folder. Instead of running wg-meshconf directly, do python -m wg_meshconf instad.

multimill commented 3 years ago

Sorry for late reply but I could not manage to make it work. Do I just need to download that .zip, extract and run the wg_meshconf.py inside it? Tried it and got this:

C:\Users\multi\Desktop\wg-meshconf_neu\wg-meshconf\wg_meshconf>python -m wg_meshconf
Traceback (most recent call last):
  File "C:\Users\multi\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\multi\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\multi\Desktop\wg-meshconf_neu\wg-meshconf\wg_meshconf\wg_meshconf.py", line 15, in <module>
    from .database_manager import DatabaseManager
ImportError: attempted relative import with no known parent package
k4yt3x commented 3 years ago

You cannot run the python file directly. You'll need to run the wg_meshconf directory as a Python package. At the root directory of the package, do python -m wg_meshconf.

multimill commented 3 years ago

Ahh I see. Thanks, I was in the wrong folder (the sub folder below the setup.py).

It's working now.

k4yt3x commented 3 years ago

Meaning that the bug is no more?

multimill commented 3 years ago

Yes, it's working as intended now. No more empty lines.

k4yt3x commented 3 years ago

Great. I'll close this issue once I release the patch. Thanks for helping out with the debugging process.