PupilTong / node-tuntap2

a opensource, asynchronized, napi-based, business friendly tuntap device addon for nodejs.
Apache License 2.0
14 stars 6 forks source link

prebuild-install 没有生效 #17

Open xiaobaidadada opened 2 months ago

xiaobaidadada commented 2 months ago

每次都是install 都是重新构建的。

stefanwerfling commented 2 months ago

You could get around this if you install this module globally npm install -g tuntap2

:)

xiaobaidadada commented 2 months ago

You could get around this if you install this module globally npm install -g tuntap2

:)

package.json 中的git地址貌似有问题,releases中也没有看到预构建的.node 可执行文件,所以prebuild-install应该不会生效。

stefanwerfling commented 2 months ago

Maybe you can try doing the following to see more. I also have the package built like this in docker:

cd yourproject/node_modules/tuntap2
npm run build --loglevel verbose

But I use my git repo in the package.json:

"dependencies": {
....
"tuntap2": "git+https://github.com/stefanwerfling/node-tuntap2.git#ESModule",
}
PupilTong commented 1 month ago

We don't have node-pre-gyp to pre build a binary for developers, that's why you need to compile it yourself. 正是因为我们没提供预编译的二进制文件,所以开发者的确需要编译它。

xiaobaidadada commented 1 month ago

We don't have node-pre-gyp to pre build a binary for developers, that's why you need to compile it yourself. 正是因为我们没提供预编译的二进制文件,所以开发者的确需要编译它。

怎么在npm搜不到了,删除了吗

stefanwerfling commented 1 month ago

The binary are generated differently for each system (x64, x86, arm, etc) and there is also a difference in the binary depending on the Node.js version and gyp. So it really is the case that these are created per system.

While looking through your projects I immediately stumbled across https://github.com/xiaobaidadada/filecat/blob/main/src/main/domain/net/tun/ts/linux/linuxtun.node. You shouldn't do that because the binary is there. The package should also be used. The code was added there.

xiaobaidadada commented 1 month ago

The binary are generated differently for each system (x64, x86, arm, etc) and there is also a difference in the binary depending on the Node.js version and gyp. So it really is the case that these are created per system.

While looking through your projects I immediately stumbled across https://github.com/xiaobaidadada/filecat/blob/main/src/main/domain/net/tun/ts/linux/linuxtun.node. You shouldn't do that because the binary is there. The package should also be used. The code was added there.

我修改了node-tuntap2,以支持windows上创建wintun,这是暂时的做法(等我有空会提交这部分代码到github),我发现PupilTong在npm删除了这个包。

stefanwerfling commented 1 month ago

@xiaobaidadada Maybe this is interesting for you, the TunTap driver is also used there via the DLL/O in Linux/Windows, just binary with Java. http://www.p2pvpn.org/documentation.html

You could of course create and collect binaries with the recognition of the platform (Windows/Linux, CPU and Nodejs version). However, the effort would be to provide all of these again with each patch.

zyeternity commented 3 weeks ago

@xiaobaidadada 您修改后的项目似乎存在一些问题,我已经尝试使用邮箱与您联系,谢谢

stefanwerfling commented 3 weeks ago

@xiaobaidadada It's also a shame that many "commits" and comments are only written in their language. This means that I can't understand what the updates should do without reading the full code.

xiaobaidadada commented 3 weeks ago

@xiaobaidadada 您修改后的项目似乎存在一些问题,我已经尝试使用邮箱与您联系,谢谢

我修改了这个bug并推送1.0.5到npm了。更多使用例子你可以参考https://github.com/xiaobaidadada/filecat 项目中最新提交的代码。

xiaobaidadada commented 3 weeks ago

@xiaobaidadada It's also a shame that many "commits" and comments are only written in their language. This means that I can't understand what the updates should do without reading the full code.

Since a large percentage of the people who follow my projects on github are Chinese, I prefer to speak in Chinese, with this in mind I will try to provide comments in both languages for English

stefanwerfling commented 3 weeks ago

@xiaobaidadada It's also a shame that many "commits" and comments are only written in their language. This means that I can't understand what the updates should do without reading the full code.

Since a large percentage of the people who follow my projects on github are Chinese, I prefer to speak in Chinese, with this in mind I will try to provide comments in both languages for English

That may be the case, I don't speak particularly good English either, my language is German. If the code runs out of English comments, I have to reject the merge and start a new project. It would no longer be tenable for me. On the other hand, I would then remove your comment in my merge. That's not supposed to be bad, but code should amount to one language :-)

@xiaobaidadada @wahaha1998 I would also like to ask you not to include binaries in the commit; As far as security goes, I can't support that. It would be the worst thing if a backdoor were introduced via such a library (here the DLLs for Windows) (I'm quoting the XZ Linux project here). Think about the trust for other developers. Otherwise, I recommend you start a private/closed project.

wintun_dll/wintun-amd64.dll

ailieg commented 3 weeks ago

These are the dlls downloaded from https://www.wintun.net/, due to the library's open source protocol I can not reference its source code, you can modify to download these dlls from the Wintun official website, I will maintain the current fork branch continue to maintain

------------------ 原始邮件 ------------------ 发件人: "Stefan @.>; 发送时间: 2024年10月24日(星期四) 下午5:56 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [PupilTong/node-tuntap2] prebuild-install 没有生效 (Issue #17)

@xiaobaidadada It's also a shame that many "commits" and comments are only written in their language. This means that I can't understand what the updates should do without reading the full code.

Since a large percentage of the people who follow my projects on github are Chinese, I prefer to speak in Chinese, with this in mind I will try to provide comments in both languages for English

That may be the case, I don't speak particularly good English either, my language is German. If the code runs out of English comments, I have to reject the merge and start a new project. It would no longer be tenable for me. On the other hand, I would then remove your comment in my merge. That's not supposed to be bad, but code should amount to one language :-)

@xiaobaidadada @wahaha1998 I would also like to ask you not to include binaries in the commit; As far as security goes, I can't support that. It would be the worst thing if a backdoor were introduced via such a library (here the DLLs for Windows) (I'm quoting the XZ Linux project here). Think about the trust for other developers. Otherwise, I recommend you start a private/closed project.

wintun_dll/wintun-amd64.dll

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

stefanwerfling commented 3 weeks ago

@wahaha1998 Then please add an install script with bash, shell, etc. which refers to these DLLs. Or instructions for the pre-setup. The advantage would be a download script that allows you to check the hash (SHA2-256: 07c256185d6ee3652e09fa55c0b673e2624b565e02c4b9091c79ca7d2f24ef51).

Of course I can understand the wish that the DLLs are included, which makes the setup easier, but trust is more important.

Sample for you (Untested):

@echo off
setlocal

REM URL and Filename
set url="https://www.wintun.net/builds/wintun-0.14.1.zip"
set filename="wintun-0.14.1.zip"
set hash_expected="07c256185d6ee3652e09fa55c0b673e2624b565e02c4b9091c79ca7d2f24ef51"
set extract_dir="C:\Path\Destination\"

REM Download
echo Download
powershell -Command "Invoke-WebRequest -Uri %url% -OutFile %filename%"

REM Create File Hash
echo Create File
for /f "tokens=* usebackq" %%A in (`powershell -Command "(Get-FileHash %filename% -Algorithm SHA256).Hash"`) do set hash_calculated=%%A

REM Check Hashs
if /i "%hash_calculated%"=="%hash_expected%" (
    echo Hash right.
) else (
    echo Error: Hash not right!
    exit /b 1
)

REM Unzip File
echo Unzip File to %extract_dir%...
powershell -Command "Expand-Archive -Path %filename% -DestinationPath %extract_dir% -Force"

echo Finish!
exit /b 0
xiaobaidadada commented 3 weeks ago

@wahaha1998 Then please add an install script with bash, shell, etc. which refers to these DLLs. Or instructions for the pre-setup. The advantage would be a download script that allows you to check the hash (SHA2-256: 07c256185d6ee3652e09fa55c0b673e2624b565e02c4b9091c79ca7d2f24ef51).

Of course I can understand the wish that the DLLs are included, which makes the setup easier, but trust is more important.

Sample for you (Untested):

@echo off
setlocal

REM URL and Filename
set url="https://www.wintun.net/builds/wintun-0.14.1.zip"
set filename="wintun-0.14.1.zip"
set hash_expected="07c256185d6ee3652e09fa55c0b673e2624b565e02c4b9091c79ca7d2f24ef51"
set extract_dir="C:\Path\Destination\"

REM Download
echo Download
powershell -Command "Invoke-WebRequest -Uri %url% -OutFile %filename%"

REM Create File Hash
echo Create File
for /f "tokens=* usebackq" %%A in (`powershell -Command "(Get-FileHash %filename% -Algorithm SHA256).Hash"`) do set hash_calculated=%%A

REM Check Hashs
if /i "%hash_calculated%"=="%hash_expected%" (
    echo Hash right.
) else (
    echo Error: Hash not right!
    exit /b 1
)

REM Unzip File
echo Unzip File to %extract_dir%...
powershell -Command "Expand-Archive -Path %filename% -DestinationPath %extract_dir% -Force"

echo Finish!
exit /b 0

I don't think this URL will necessarily download successfully, and if it fails the installation will fail. Wintun.setpath method can to specify the DLL of installer downloaded DLL himself from https://www.wintun.net/ , which can be supplemented by readme file

stefanwerfling commented 3 weeks ago

I don't think this URL will necessarily download successfully, and if it fails the installation will fail. Wintun.setpath method can to specify the DLL of installer downloaded DLL himself from https://www.wintun.net/ , which can be supplemented by readme file

Then you can remove the dlls from the commit? I hardly believe that the download will fail, there is a higher probability that I have problems with dependencies in the npm install ;-)

xiaobaidadada commented 3 weeks ago

I don't think this URL will necessarily download successfully, and if it fails the installation will fail. Wintun.setpath method can to specify the DLL of installer downloaded DLL himself from https://www.wintun.net/ , which can be supplemented by readme file

Then you can remove the dlls from the commit? I hardly believe that the download will fail, there is a higher probability that I have problems with dependencies in the npm install ;-)

you can do it, i prefer this method to install

stefanwerfling commented 3 weeks ago

I don't think this URL will necessarily download successfully, and if it fails the installation will fail. Wintun.setpath method can to specify the DLL of installer downloaded DLL himself from https://www.wintun.net/ , which can be supplemented by readme file

Then you can remove the dlls from the commit? I hardly believe that the download will fail, there is a higher probability that I have problems with dependencies in the npm install ;-)

you can do it, i prefer this method to install

Feel free to do that in your private repositories, I hope @PupilTong will reject your merge. As I said, your binary files have no place in the code repository. If you want a user-friendly install, provide an install script. Finished programs are usually offered as setup.exe, which you can do in the github release. But it can't be the case that if I run the clone project or npm install it will automatically bring any unchecked binary libraries onto my system.

xiaobaidadada commented 3 weeks ago

I don't think this URL will necessarily download successfully, and if it fails the installation will fail. Wintun.setpath method can to specify the DLL of installer downloaded DLL himself from https://www.wintun.net/ , which can be supplemented by readme file

Then you can remove the dlls from the commit? I hardly believe that the download will fail, there is a higher probability that I have problems with dependencies in the npm install ;-)

you can do it, i prefer this method to install

Feel free to do that in your private repositories, I hope @PupilTong will reject your merge. As I said, your binary files have no place in the code repository. If you want a user-friendly install, provide an install script. Finished programs are usually offered as setup.exe, which you can do in the github release. But it can't be the case that if I run the clone project or npm install it will automatically bring any unchecked binary libraries onto my system.

ok I'll make some changes to provide an installation function to dowoad dll in my fork branch after same days

PupilTong commented 1 week ago

We don't have node-pre-gyp to pre build a binary for developers, that's why you need to compile it yourself. 正是因为我们没提供预编译的二进制文件,所以开发者的确需要编译它。

怎么在npm搜不到了,删除了吗

@xiaobaidadada

image

Could you please check your npm mirror?