英文:
Run traceroute from a minecraft plugin
问题
我最近想要创建一个插件,可以从服务器向玩家运行traceroute。由于我的服务器托管不允许我访问除了Minecraft部分之外的其他文件,所以我在使用Java方面遇到了一些困难,无法正确设置所需的库。
我考虑创建一个Rest API,部署在我拥有所有权限的VPS上,但我不确定是否可以从与本地IP不同的IP运行traceroute,并且我需要从Minecraft服务器运行它以跟踪玩家。
我目前使用的traceroute是这个:https://gist.github.com/djangofan/1d0e3de52ac5375d3f52249c5293d588
问题是它使用了Jpcap,这是一个本地库,因此它需要通过不同的系统属性进行设置,而这在我的服务器托管中是不允许的。
你会如何处理?
英文:
I recently wanted to create a plugin that would run a traceroute from the server to a player.
I have some struggles with java cause my server hosting doesn't allow me to have access to other file than the minecraft part, so i can't setup correctly the libraries i need.
I thought about creating a Rest API that would be on a VPS where i have all permissions, but i'm not sure we can run a traceroute from another IP than the local one, and i need to run it from the minecraft server to the player.
The traceroute that i currently use is this one: https://gist.github.com/djangofan/1d0e3de52ac5375d3f52249c5293d588
The problem is that it uses Jpcap, which is a native library and therefore it requires to set it up via different system properties etc which i'm not allowed with my server hosting.
How would you do ?
答案1
得分: 0
I assume that you and the server operator are no longer friends when you do something like this … but that's your decision.
When you can't apply the native library to the server, your only option would be to re-implement traceroute in Java – although I have no clue if the JVM has deep enough access into the system as that might be possible at all.
If you can write to the file system of your Minecraft server, and when you upload a JAR to it, in order to install the plugin, you can add the native library as a binary resource to the JAR. If you can upload only a class, you can add the library as a big BASE64 String to that class.
Before you start your traceroute, you write the native library out to the file system, then you call System.load() for it, and finally you execute the traceroute. – But this definitely belongs to the category "Dirty Hack", as it may destabilize the server, and it may not even work, because of an active SecurityManager that prevents you from doing so.
When the traceroute library does the call to System.load() (or System.loadLibrary()) itself, you may get along with manipulating the property java.library.path instead of calling System.load(), but again, an active SecurityManager could prevent that …
英文:
I assume that you and the server operator are no longer friends when you do something like this … but that's your decision.
When you can't apply the native library to the server, your only option would be to re-implement traceroute
in Java – although I have no clue if the JVM has deep enough access into the system as that might be possible at all.
If you can write to the file system of your Minecraft server, and when you upload a JAR to it, in order to install the plugin, you can add the native library as a binary resource to the JAR. If you can upload only a class, you can add the library as a big BASE64 String to that class.
Before you start your traceroute, you write the native library out to the file system, then you call System.load()
for it, and finally you execute the traceroute. – But this definitely belongs to the category "Dirty Hack", as it may destabilise the server, and it may not even work, because of an active SecurityManager
that prevents you from doing so.
When the traceroute library does the call to System.load()
(or System.loadLibrary()
) itself, you may get along with manipulating the property java.library.path
instead of calling System.load()
, but again, an active SecurityManager
could prevent that …
专注分享java语言的经验与见解,让所有开发者获益!
评论