Skip to content

APIs needed for syncthing-android #192

Closed

Description

@Nutomic

These will probably need to be called directly in Go, as we don't know the web interface yet:

  • set config folder
  • get web ui adress

These can be done over the event interface:

Activity

  1. calmh commented on May 11, 2014

    @calmh
    Member

    For the first two, could not the android "wrapper" simply pre-generate the config file with the desired GUI port etc and start syncthing with the appropriate -home option? Note that you can start with a config like the following:

    <configuration version="2">
        <repository id="default" directory="whateverdir">
        </repository>
        <gui enabled="true">
            <address>127.0.0.1:8080</address>
        </gui>
        <options>
            <listenAddress>:22000</listenAddress>
            <globalAnnounceServer>announce.syncthing.net:22025</globalAnnounceServer>
            <globalAnnounceEnabled>true</globalAnnounceEnabled>
            <localAnnounceEnabled>true</localAnnounceEnabled>
            <parallelRequests>16</parallelRequests>
            <maxSendKbps>50</maxSendKbps>
            <rescanIntervalS>60</rescanIntervalS>
            <reconnectionIntervalS>60</reconnectionIntervalS>
            <maxChangeKbps>1000</maxChangeKbps>
            <startBrowser>false</startBrowser>
            <upnpEnabled>true</upnpEnabled>
        </options>
    </configuration>
    

    (i.e. without mentioning any nodes). Syncthing will create it's keys when starting up, and will do the right thing with the config when you add nodes etc in the GUI.

    For the last three,

    1. Pass host/port - yep, this will need something dynamic (don't want to change the config and restart for every change). Easy to add.
    2. Can already be done Could actually be done in a previous version. I'll add it back in, as a HTTP POST to /rest/shutdown (similar to /rest/restart that already exists).
    3. Can already be done - you can GET, edit then POST /rest/config.
  2. added a commit that references this issue on May 11, 2014
  3. Nutomic commented on May 11, 2014

    @Nutomic
    ContributorAuthor

    That looks pretty simple actually, awesome!

  4. Nutomic commented on May 12, 2014

    @Nutomic
    ContributorAuthor

    Does it matter that globalAnnounceServer is announce.syncthing.net:22025 in your config, but syncthing.nym.se:22025 in my autogenerated one?

    Also, how should I check that the shutdown is completed? Just poll until the webserver is unavailable?

    Edit: passing -home doesn't work, as I use System.loadLibrary() which doesn't pass command line parameters. This guy got it running from the command line, but I didn't manage that right now. Anyway this isn't really important, as the data folder should really be the same across all Android versions (I just don't like hardcoding it).

  5. Nutomic commented on May 12, 2014

    @Nutomic
    ContributorAuthor

    How exactly do I call shutdown? When I request http://127.0.0.1:8080/rest/shutdown, that just gives me a page with "404 page not found".

    I did check out HEAD (abbb40) and run ./build.sh assets.

  6. calmh commented on May 12, 2014

    @calmh
    Member

    You need to make a POST, not a GET. I.e. curl -X POST http://.../rest/shutdown.

  7. Nutomic commented on May 12, 2014

    @Nutomic
    ContributorAuthor

    Ok it took me a while to figure it out (I tried to pass rest/shutdown as parameter, stupid me).

    The thing is now, rest/shutdown does nothing, while rest/restart works. I did go clean, deleted golang/bin and golang/pkg, but that didn't help. The call returns 200, but the web ui keeps running.

  8. calmh commented on May 12, 2014

    @calmh
    Member

    Certainly shuts down for me, when running the integration test on darwin-amd64 and linux-amd64...

  9. Nutomic commented on May 13, 2014

    @Nutomic
    ContributorAuthor

    Ok it isn't actually a restart, it just crashes when accessing os.Args[0].

    How does stop (set in shutdown()) work, so I can see where it's going wrong?

  10. calmh commented on May 13, 2014

    @calmh
    Member

    It simply lets syncthing return from main(); the last line in main() is a read from the stop channel.

  11. calmh commented on May 13, 2014

    @calmh
    Member

    ^ that adds the ability to give hints to the discovery mechanism. Use like this:

    curl -X POST 'http://localhost:8080/rest/discovery/hint?node=ABCDEFGHIJKLMNOPQRSTUVXYZ&addr=10.2.3.4:22000'

  12. Nutomic commented on May 13, 2014

    @Nutomic
    ContributorAuthor

    So it does return from main, but the web interface is still accessible.

    Edit: maybe this happens because memory isn't released, I'll look into that.

    Edit 2: I solved this by explicitly stopping the Java VM. Not a beautiful solution, but the only one I could find.

  13. Nutomic commented on May 14, 2014

    @Nutomic
    ContributorAuthor

    It would also be nice if there was a "pause" and "unpause" API call, so we don't have any traffic on mobile data (I can make that a seperate issue if you wish).

  14. calmh commented on May 14, 2014

    @calmh
    Member

    Please do; it makes sense to add.

  15. calmh commented on May 14, 2014

    @calmh
    Member

    I'm closing this "mixed bag" issue, please reopen issues on stuff that remain and/or is problematic. :)

  16. added
    frozen-due-to-age
    on Jun 17, 2017
  17. locked and limited conversation to collaborators on Jun 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    frozen-due-to-age

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions