GithubHelp home page GithubHelp logo

moson-mo / goaurrpc Goto Github PK

View Code? Open in Web Editor NEW
9.0 1.0 2.0 11.21 MB

An implementation of the aurweb (v6) - /rpc - REST API service in go

License: MIT License

Go 88.80% Shell 0.11% Dockerfile 0.31% HTML 10.79%
aur arch rest-api rest in-memory-database archlinux aur-packages packages

goaurrpc's Introduction

goaurrpc

Release GitHub Workflow Status Coverage Go Report Card

An implementation of the aurweb (v6) - /rpc - REST API service in go

goaurrpc allows you to run your own self-hosted aurweb /rpc endpoint.
This project implements the /rpc interface (REST API; version 5) as described here.

In it's default configuration, package data is being downloaded/refreshed from the AUR every 5 minutes.
The data is entirely held in-memory as opposed to storing it in a database for example.
This avoids the need to make heavy database queries for each request.
For a performance comparison, see Benchmarks

How to build

  • Download repository git clone https://github.com/moson-mo/goaurrpc.git
  • cd goaurrpc
  • Build with: ./build.sh
  • This will create a binary goaurrpc

Config file

See sample.conf file. The config file can be loaded by specifying "-c" parameter when running goaurrpc.
For example: ./goaurrpc -c sample.conf. If this parameter is not passed, the default config will be used (sample.conf contains the defaults).

{
	"Port": 10666,
	"AurFileLocation": "https://aur.archlinux.org/packages-meta-ext-v1.json.gz",
	"MaxResults": 5000,
	"RefreshInterval": 300,
	"RateLimit": 4000,
	"LoadFromFile": false,
	"RateLimitCleanupInterval": 600,
	"RateLimitTimeWindow": 86400,
	"TrustedReverseProxies": [
		"127.0.0.1",
		"::1"
	],
	"EnableSSL": false,
	"CertFile": "",
	"KeyFile": "",
	"EnableSearchCache": true,
	"CacheCleanupInterval": 60,
	"CacheExpirationTime": 180,
	"EnableMetrics": true,
	"EnableAdminApi": false,
	"AdminAPIKey": "change-me"
}
Setting Description
Port The port number our service is listening on
AurFileLocation Either the URL to the full metadata archive packages-meta-ext-v1.json.gz or a local copy of the file
MaxResults The maximum number of package results that are being returned to the client
RefreshInterval The interval (in seconds) in which the metadata file is being reloaded
RateLimit The maximum number of requests that are allowed within the time-window
LoadFromFile Set to true when using a local file instead of a URL for AurFileLocation
RateLimitCleanupInterval The interval (in seconds) in which rate-limits are being cleaned up
RateLimitTimeWindow Defines the length of the time window for rate-limiting (in seconds)
Trusted reverse proxies A list of trusted IP-Addresses, in case you use a reverse proxy and need to rely on X-Real-IP or X-Forwarded-For headers to identify a client (for rate-limiting)
EnableSSL Enables internal SSL/TLS. You'll need to provide CertFileand KeyFile when enabling it. I'd recommend to use nginx as reverse proxy to add encryption instead
CertFile Path to the cert file (if SSL is enabled)
KeyFile Path to the corresponding key file (if SSL is enabled)
EnableSearchCache Caches data for search queries that have been performed by clients
CacheCleanupInterval The interval (in seconds) for performing cleanup of search-cache entries
CacheExpirationTime The number of seconds an entry should stay in the search-cache
EnableMetrics Enables Prometheus metrics at /metrics
EnableAdminApi Enables the administrative endpoint at /admin
AdminAPIKey The API Key that is to be provided in the header for the /admin endpoint

Public endpoint

Feel free to make use of the following public instance of goaurrpc:

HTTP / HTTPS

Future plans / ideas

  • Extend request types (see v6-proposal branch)
  • Admin REST-API to be able to control goaurrpc at runtime, for example:
    • reload data
    • get statistics (memory consumption, rate limits, etc.)
    • manage rate-limits
    • manage search-cache
  • CLI/TUI tool for administration (making use of the admin api)

goaurrpc's People

Contributors

dpeukert avatar hrkings avatar moson-mo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

hrkings inglor

goaurrpc's Issues

"Arg too small" on info requests with 1 letter

When using upstream aurweb, a request such as

curl 'https://aur.archlinux.org/rpc?v=5&type=inf&arg[]=r' 

leads to:

{"resultcount":0,"results":[],"type":"multiinfo","version":5}

However, with goaurrpc (using the server.moson.rocks/rpc instance) I have:

{"error":"Query arg too small.","resultcount":0,"results":[],"type":"error","version":5c

This is the behavior aurweb would have when a 1-character search is done. However, for info-type requests having a single-letter term is valid, as package names may consist of 1 letter.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.