BiglySoftware / BiglyBT-plugin-azjscripter

Provides JavaScript features to Vuze for automation purposes.
2 stars 1 forks source link

Interface name misspelled in JS bindings!? #1

Closed ferdnyc closed 2 years ago

ferdnyc commented 2 years ago

@parg @TuxPaper

So, I was looking to use the JS scripting interface to implement a tag action-on-apply that isn't part of the available set. (Auto-disabling IPFilter for torrents with a certain tag, because the BiglyBT system torrent tracker is hosted on AWS, and AWS is part of my IPFilter list.) I made my way to the wiki and read about this plugin, enabled it, and then read further and learned about init.js. So I looked in that file.

And I discovered this: https://github.com/BiglySoftware/BiglyBT-plugin-azjscripter/blob/53afde93e685baeef580e50c1f8cd5809632c16d/init.js#L11-L21

Note the spelling of all of the imports classes:

com.biglbybt.pif...
    ^^^^^^^^

That's... um... not gonna be a problem? It actually works like that? :confused:

ferdnyc commented 2 years ago

Biglby_Tuna

ferdnyc commented 2 years ago

I made my way to the wiki and read about this plugin, enabled it, and then read further and learned about init.js.

* — (Note that I'm not necessarily planning to use the init.js imports in my tag action1. I just thought it would be a good idea for that file to use the correct class names, regardless whether or not I need it for my current plans.)

  1. If I understood the wiki info correctly, to use vuzeimports from init.js I'd have to implement the constraint as a plugin. Whereas I'm hoping I can get away with just adding some inline JS to the tag configuration. (Do I need more than the download binding provided by the constraint context? I know the Java implementation of the "Enable IP Filter" context menu item would set FLAG_DISABLE_IP_FILTER on the download, which would in turn trigger this call:
    IpFilterManagerFactory.getSingleton()
                          .getIPFilter()
                          .addExcludedHash( torrent.getHash());

    ...which would cause the torrent to be allow-listed in the IP filtering, and therefore exempt. But can I set that flag myself and let the Java do the work, or do I have to import com.biglybt.pif.ipfilter and actually call addExcludedHash() directly from the JS?)

parg commented 2 years ago

Whoaaaa! As you can see, nobody uses it :) Unfortunately for quite a while the Java developers threatened to remove support and have actually done so in Java 15:

https://openjdk.java.net/jeps/372

Which is why I have been ignoring it. A shame really, when I initially developed it I thought it could turn into something cool but in reality nobody could be arsed to try and use it so it never evolved.

Recently I created the "SimpleAPI plugin" that supports a few basic operations, I could add an "ipfilterenabled" to "setdownloadattribute" ?

https://github.com/BiglySoftware/BiglyBT/wiki/Plugins#simple-api

It was initially developed to work in conjunction with something like the "command runner" plugin but I also extended it so it can be invoked from a Tag (see at the bottom)

parg commented 2 years ago

(added in the upcoming B11 along with a Tag constraint function "isIpFiltered()" in case of use)

ferdnyc commented 2 years ago

@parg

Whoaaaa! As you can see, nobody uses it :)

Heyyy, maaaaaan. It's only been 23 months since the last code commit to this repo, you've gotta give these things time! (Of course, the code's really been there, spelled the same way, in one form or another since 2017. So, yeah.)

Once could argue there's a bit of a chicken-and-egg problem: Obviously nobody uses it now, because it doesn't work! Who knows if anyone tried to use it, failed, and gave up? (...I assume neither of us is buying that, tho. Right? I'm for sure not.)

Unfortunately for quite a while the Java developers threatened to remove support and have actually done so in Java 15:

Java fifteen!?!? Man, and here I was feeling like FutureMan™ just because I'm running under Java 11 instead of 1.8 / 8! I know, intellectually, that there are Javas 14, 15, 16, and even 17, but they feel like the far-off future still given how doggedly 1.8 has clung to life.

It's a lot like C++ standard levels — there's so much good stuff in C++11 that widespread adoption is pretty much the norm at this point (thankfully!), but even though there's also plenty of good stuff in C++17 and even more in C++20, realistically nobody can dare use it, and probably won't until Ubuntu 18.04 is finally put out of our collective misery in 2023.

But, yeah, having it dropped from the language is pretty much game over, not a lot of reason to dump additional resources into maintaining an evolutionary cul-de-sac. Does seem like a shame.

I did notice that Java 17 adds an experimental foreign-function interface, finally, which in theory would allow linking any JS engine with a C API into BiglyBT. So, that might be a revival path.

Seems like you guys will have your hands full already, migrating to newer JDK standards. A jdeprscan run against the current beta JAR using even --release 9 is... talkative, hundreds fo messages. Though like 90% of them are just repeated whining about uses of certain java/lang/{Integer,Float,Double,String} constructors, which I guess got a re-working. (The rest mostly concerns Object::finalize, or the java/applet/ classes` they've also pulled the plug on.)

Running the scan against the Java 17 standard adds in a couple dozen more, which presumably are actually meaningful. (In contrast to the hundreds and hundreds of lines that are just repeated complaints about deprecated constructors, which are.. less meaningful.)

$ jdeprscan --release 9 BiglyBT.jar 2>/dev/null|wc -l
323

$ # (But like I said...)
$ jdeprscan --release 9 BiglyBT.jar 2>/dev/null \
|egrep -v 'java/lang/(Integer|Long|Float|Double|String)::<init>' |wc -l 
29

$ jdeprscan --release 11 BiglyBT.jar 2>/dev/null \
|egrep -v 'java/lang/(Integer|Long|Float|Double|String)::<init>' |wc -l 
29

$ jdeprscan --release 14 BiglyBT.jar 2>/dev/null \
|egrep -v 'java/lang/(Integer|Long|Float|Double|String)::<init>' |wc -l 
30

$ jdeprscan --release 17 BiglyBT.jar 2>/dev/null \
|egrep -v 'java/lang/(Integer|Long|Float|Double|String)::<init>' |wc -l 
48

...To say nothing of all the plugins.

Recently I created the "SimpleAPI plugin" that supports a few basic operations, I could add an "ipfilterenabled" to "setdownloadattribute" ?

That sounds fine, I'd seen those earlier commits go by but I hadn't had a chance (or need) to try it out so far. But I'll give the new calls in B11 a spin, sounds like it'll do exactly what I need. Thanks!

ferdnyc commented 2 years ago

Actually, here's the full output (minus constructor deprecation warnings) relative to the Java 17 standard. At least none of it's actually removed, so far, still just future-incompatibility warnings. Looks like an update to a newer bouncycastle (assuming such a thing exists) could hopefully solve about 20% of them:

$ jdeprscan --release 17 BiglyBT.jar 2>/dev/null \
|egrep -v 'java/lang/(Integer|Long|Float|Double|String)::<init>'
Jar file BiglyBT.jar:
class com/biglybt/plugin/net/buddy/swt/BuddyPluginView$13 uses deprecated class java/applet/Applet (forRemoval=true)
class com/biglybt/plugin/net/buddy/swt/BuddyPluginView$13 uses deprecated class java/applet/AudioClip (forRemoval=true)
class com/biglybt/plugin/net/netstatus/swt/NetStatusPluginTester uses deprecated method java/security/cert/X509Certificate::getSubjectDN()Ljava/security/Principal; 
class com/biglybt/ui/swt/UserAlerts$8 uses deprecated class java/applet/AudioClip (forRemoval=true)
class com/biglybt/ui/swt/UserAlerts uses deprecated class java/applet/Applet (forRemoval=true)
class com/biglybt/ui/swt/UserAlerts has field named audio_clip of deprecated type java/applet/AudioClip (forRemoval=true)
class com/biglybt/ui/swt/UserAlerts has method named access$8 having deprecated return type java/applet/AudioClip (forRemoval=true)
class com/biglybt/ui/swt/auth/CertificateTrustWindow$trustDialog uses deprecated method java/security/cert/X509Certificate::getIssuerDN()Ljava/security/Principal; 
class com/biglybt/ui/swt/auth/CertificateTrustWindow$trustDialog uses deprecated method java/security/cert/X509Certificate::getSubjectDN()Ljava/security/Principal; 
class com/biglybt/ui/swt/views/configsections/ConfigSectionInterfaceAlertsSWT$1 uses deprecated class java/applet/Applet (forRemoval=true)
class com/biglybt/ui/swt/views/configsections/ConfigSectionInterfaceAlertsSWT$1 uses deprecated class java/applet/AudioClip (forRemoval=true)
class com/biglybt/core/config/COConfigurationManager uses deprecated class java/security/AccessControlException (forRemoval=true)
class com/biglybt/core/internat/MessageText uses deprecated method java/io/File::toURL()Ljava/net/URL; 
class com/biglybt/core/peermanager/messaging/bittorrent/ltep/LTMessageEncoder uses deprecated method java/lang/Byte::<init>(B)V (forRemoval=true)
class com/biglybt/core/security/impl/SESecurityManagerImpl$ClientSecurityManager extends deprecated class java/lang/SecurityManager (forRemoval=true)
class com/biglybt/core/security/impl/SESecurityManagerImpl$ClientSecurityManager uses deprecated class java/lang/SecurityManager (forRemoval=true)
class com/biglybt/core/security/impl/SESecurityManagerImpl$ClientSecurityManager has field named old_sec_man of deprecated type java/lang/SecurityManager (forRemoval=true)
class com/biglybt/core/security/impl/SESecurityManagerImpl$ClientSecurityManager has method named <init> having deprecated parameter type java/lang/SecurityManager (forRemoval=true)
class com/biglybt/core/security/impl/SESecurityManagerImpl$ClientSecurityManager has method named <init> having deprecated parameter type java/lang/SecurityManager (forRemoval=true)
class com/biglybt/core/security/impl/SESecurityManagerImpl uses deprecated method java/lang/System::getSecurityManager()Ljava/lang/SecurityManager; (forRemoval=true)
class com/biglybt/core/security/impl/SESecurityManagerImpl uses deprecated method java/lang/System::setSecurityManager(Ljava/lang/SecurityManager;)V (forRemoval=true)
class com/biglybt/core/security/impl/SESecurityManagerImpl uses deprecated method java/lang/Thread::stop()V 
interface com/biglybt/core/tracker/client/TRTrackerScraperClientResolver uses deprecated method java/lang/Character::<init>(C)V (forRemoval=true)
class com/biglybt/core/util/NetUtils$1 uses deprecated class java/lang/SecurityManager (forRemoval=true)
class com/biglybt/core/util/NetUtils$1 uses deprecated method java/lang/System::getSecurityManager()Ljava/lang/SecurityManager; (forRemoval=true)
class com/biglybt/core/util/UrlUtils uses deprecated method java/net/URLEncoder::encode(Ljava/lang/String;)Ljava/lang/String; 
class com/biglybt/core/util/UrlUtils uses deprecated method java/net/URLDecoder::decode(Ljava/lang/String;)Ljava/lang/String; 
class com/biglybt/core/util/FileUtil$FileHack uses deprecated method java/io/File::toURL()Ljava/net/URL; 
class com/biglybt/core/util/FileUtil$FileHack overrides deprecated method java/io/File::toURL()Ljava/net/URL; 
class com/biglybt/core/util/Constants uses deprecated class java/security/AccessControlException (forRemoval=true)
class com/biglybt/core/util/jar/AEJarSigner2 uses deprecated method java/io/File::toURL()Ljava/net/URL; 
class com/biglybt/net/udp/mc/impl/MCGroupImpl uses deprecated method java/net/MulticastSocket::setLoopbackMode(Z)V 
class com/biglybt/net/upnp/impl/UPnPImpl uses deprecated method java/lang/Character::<init>(C)V (forRemoval=true)
class com/biglybt/net/upnp/impl/device/UPnPRootDeviceImpl uses deprecated method java/lang/Character::<init>(C)V (forRemoval=true)
class com/biglybt/pifimpl/local/launch/PluginLauncherImpl uses deprecated method java/io/File::toURL()Ljava/net/URL; 
class com/biglybt/platform/macosx/access/cocoa/CocoaJavaBridge uses deprecated method java/lang/Object::finalize()V 
class com/biglybt/platform/macosx/access/cocoa/CocoaJavaBridge overrides deprecated method java/lang/Object::finalize()V 
class com/biglybt/update/CoreUpdateChecker uses deprecated method java/io/File::toURL()Ljava/net/URL; 
class org/gudy/bouncycastle/jce/PKCS7SignedData uses deprecated method java/security/cert/X509Certificate::getIssuerDN()Ljava/security/Principal; 
class org/gudy/bouncycastle/jce/provider/X509CertificateObject overrides deprecated method java/security/cert/X509Certificate::getIssuerDN()Ljava/security/Principal; 
class org/gudy/bouncycastle/jce/provider/X509CertificateObject overrides deprecated method java/security/cert/X509Certificate::getSubjectDN()Ljava/security/Principal; 
class org/gudy/bouncycastle/jce/provider/JDKDigestSignature overrides deprecated method java/security/SignatureSpi::engineSetParameter(Ljava/lang/String;Ljava/lang/Object;)V 
class org/gudy/bouncycastle/jce/provider/JDKDigestSignature overrides deprecated method java/security/SignatureSpi::engineGetParameter(Ljava/lang/String;)Ljava/lang/Object; 
class org/gudy/bouncycastle/jce/provider/BouncyCastleProvider uses deprecated method java/security/Provider::<init>(Ljava/lang/String;DLjava/lang/String;)V 
class org/gudy/bouncycastle/jce/provider/JDKDSASigner overrides deprecated method java/security/SignatureSpi::engineSetParameter(Ljava/lang/String;Ljava/lang/Object;)V 
class org/gudy/bouncycastle/jce/provider/JDKDSASigner overrides deprecated method java/security/SignatureSpi::engineGetParameter(Ljava/lang/String;)Ljava/lang/Object; 
class org/gudy/bouncycastle/jce/provider/X509CRLObject overrides deprecated method java/security/cert/X509CRL::getIssuerDN()Ljava/security/Principal; 
ferdnyc commented 2 years ago

@parg

Hmm, it should be this, correct?

http://localhost:6906/?apikey=$KEY&method=setdownloadattribute&name=ipfilterenabled&value=false&hash=$HASH

I'm getting "invalid 'name' parameter (ipfilterenabled)" with _B11, even in an external browser window (that processed the test-URL just fine).

ferdnyc commented 2 years ago

Ah, I see it now. In the commit it's ipfilterenable, without the 'd'.

ferdnyc commented 2 years ago

Sweet, that's got it. Execute on assign, script=

plugin( simpleapi, "method=setdownloadattribute&name=ipfilterenable&value=false" )

:+1: Cool beans! Thanks, this'll definitely make it easier to download future Beta updates and plugins.

parg commented 2 years ago

Thanks for the deprecations, I suppose I should go through them sometime :(

ferdnyc commented 2 years ago

@parg

Joke's on me, anyway — after all this, it turns out I should've just looked through the Options.

You added this in BiglySoftware/BiglyBT@92f2282905e513deeca2cb5de2b93177cb249457 :rofl: (November 2017, for anyone keeping score):

image

parg commented 2 years ago

who would have known :)