From 75ac54dad5f888f6b221350c74b03199b385d8de Mon Sep 17 00:00:00 2001 From: jschaul Date: Tue, 31 Mar 2026 14:53:59 +0200 Subject: [PATCH] Sunset restund (and rex) --- Makefile | 4 +- README.md | 1 - cabal.project | 1 - changelog.d/0-release-notes/restund.md | 1 + charts/restund/Chart.yaml | 14 - charts/restund/README.md | 14 - charts/restund/templates/_helpers.tpl | 51 -- charts/restund/templates/ca-configmap.yaml | 9 - .../configmap-restund-conf-template.yaml | 62 -- .../templates/secret-or-certificate.yaml | 41 -- charts/restund/templates/secret.yaml | 11 - charts/restund/templates/service-account.yaml | 33 - charts/restund/templates/service.yaml | 20 - charts/restund/templates/statefulset.yaml | 163 ----- charts/restund/values.yaml | 74 -- docs/src/how-to/install/sft.md | 4 +- docs/src/how-to/install/troubleshooting.md | 4 +- nix/local-haskell-packages.nix | 1 - services/restund/.gitignore | 29 - services/restund/Dockerfile | 27 - services/restund/LICENSE | 661 ------------------ services/restund/Makefile | 112 --- services/restund/README.md | 154 ---- services/restund/modules/drain/drain.c | 144 ---- services/restund/modules/drain/module.mk | 23 - services/restund/modules/zrest/module.mk | 23 - services/restund/modules/zrest/zrest.c | 283 -------- tools/rex/.ormolu | 1 - tools/rex/LICENSE | 661 ------------------ tools/rex/Main.hs | 376 ---------- tools/rex/README.md | 11 - tools/rex/default.nix | 56 -- tools/rex/rex.cabal | 46 -- treefmt.toml | 1 - 34 files changed, 7 insertions(+), 3109 deletions(-) create mode 100644 changelog.d/0-release-notes/restund.md delete mode 100644 charts/restund/Chart.yaml delete mode 100644 charts/restund/README.md delete mode 100644 charts/restund/templates/_helpers.tpl delete mode 100644 charts/restund/templates/ca-configmap.yaml delete mode 100644 charts/restund/templates/configmap-restund-conf-template.yaml delete mode 100644 charts/restund/templates/secret-or-certificate.yaml delete mode 100644 charts/restund/templates/secret.yaml delete mode 100644 charts/restund/templates/service-account.yaml delete mode 100644 charts/restund/templates/service.yaml delete mode 100644 charts/restund/templates/statefulset.yaml delete mode 100644 charts/restund/values.yaml delete mode 100644 services/restund/.gitignore delete mode 100644 services/restund/Dockerfile delete mode 100644 services/restund/LICENSE delete mode 100644 services/restund/Makefile delete mode 100644 services/restund/README.md delete mode 100644 services/restund/modules/drain/drain.c delete mode 100644 services/restund/modules/drain/module.mk delete mode 100644 services/restund/modules/zrest/module.mk delete mode 100644 services/restund/modules/zrest/zrest.c delete mode 120000 tools/rex/.ormolu delete mode 100644 tools/rex/LICENSE delete mode 100644 tools/rex/Main.hs delete mode 100644 tools/rex/README.md delete mode 100644 tools/rex/default.nix delete mode 100644 tools/rex/rex.cabal diff --git a/Makefile b/Makefile index 49407d77299..505dec9c146 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ DOCKER_TAG ?= $(USER) # default helm chart version must be 0.0.42 for local development (because 42 is the answer to the universe and everything) HELM_SEMVER ?= 0.0.42 # The list of helm charts needed on internal kubernetes testing environments -CHARTS_INTEGRATION := wire-server databases-ephemeral rabbitmq fake-aws ingress-nginx-controller nginx-ingress-services fluent-bit kibana restund k8ssandra-test-cluster wire-server-enterprise +CHARTS_INTEGRATION := wire-server databases-ephemeral rabbitmq fake-aws ingress-nginx-controller nginx-ingress-services fluent-bit kibana k8ssandra-test-cluster wire-server-enterprise # The list of helm charts to publish on S3 # FUTUREWORK: after we "inline local subcharts", # (e.g. move charts/brig to charts/wire-server/brig) @@ -17,7 +17,7 @@ CHARTS_RELEASE := wire-server redis-ephemeral rabbitmq rabbitmq-external databas fake-aws fake-aws-s3 fake-aws-sqs aws-ingress fluent-bit kibana backoffice \ calling-test demo-smtp elasticsearch-curator elasticsearch-external \ elasticsearch-ephemeral minio-external cassandra-external \ -ingress-nginx-controller nginx-ingress-services reaper restund \ +ingress-nginx-controller nginx-ingress-services reaper \ k8ssandra-test-cluster ldap-scim-bridge wire-server-enterprise KIND_CLUSTER_NAME := wire-server HELM_PARALLELISM ?= 1 # 1 for sequential tests; 6 for all-parallel tests diff --git a/README.md b/README.md index ffd0519e620..34d6b7c62c6 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,6 @@ This repository contains the following source code: - **cannon**: WebSocket Push Notifications - **cargohold**: Asset (image, file, ...) Storage - **proxy**: 3rd Party API Integration - - **restund**: STUN/TURN server for use in Audio/Video calls - **spar**: Single-Sign-On (SSO) - **tools** diff --git a/cabal.project b/cabal.project index 9e1051b8478..1cf1aa8ecbc 100644 --- a/cabal.project +++ b/cabal.project @@ -56,7 +56,6 @@ packages: , tools/db/repair-brig-clients-table/ , tools/db/service-backfill/ , tools/rabbitmq-consumer - , tools/rex/ , tools/stern/ , tools/mlsstats/ , tools/test-stats/ diff --git a/changelog.d/0-release-notes/restund.md b/changelog.d/0-release-notes/restund.md new file mode 100644 index 00000000000..404abceeb1a --- /dev/null +++ b/changelog.d/0-release-notes/restund.md @@ -0,0 +1 @@ +The Restund helm chart and code stops being supported and shipped. If you have not already, please migrate to coturn which continues to be supported. diff --git a/charts/restund/Chart.yaml b/charts/restund/Chart.yaml deleted file mode 100644 index 87cf4ae6f96..00000000000 --- a/charts/restund/Chart.yaml +++ /dev/null @@ -1,14 +0,0 @@ -apiVersion: v2 -name: restund -description: Restund - a modular STUN/TURN server -type: application - -# This is the chart version. This version number should be incremented each time you make changes -# to the chart and its templates, including the app version. -# Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.1.0 - -# This is the version number of the application being deployed. This version number should be -# incremented each time you make changes to the application. Versions are not expected to -# follow Semantic Versioning. They should reflect the version the application is using. -appVersion: v0.6.0-rc.1 diff --git a/charts/restund/README.md b/charts/restund/README.md deleted file mode 100644 index 8af0d2d3446..00000000000 --- a/charts/restund/README.md +++ /dev/null @@ -1,14 +0,0 @@ -This chart deploys [Restund](https://docs.wire.com/understand/restund.html), a -STUN and TURN server. - -You need to supply the zrestSecret at key `secrets.zrestSecret`. Make sure this -matches `secrets.turn.secret` of the brig chart. - -Restund pods are deployed with `hostNetwork: true`, because restund needs to -listen on a wide range of udp ports. See `values.yaml` for additional tcp ports -that need to be exposed on the hosting node. - -The Restund server might also expose the internal network to which the hosting -node is connected to. It is therefore recommended to run restund on a separate -network (cluster) than the rest of wire's services. See -[details](https://docs.wire.com/understand/restund.html#network). diff --git a/charts/restund/templates/_helpers.tpl b/charts/restund/templates/_helpers.tpl deleted file mode 100644 index af75bb10977..00000000000 --- a/charts/restund/templates/_helpers.tpl +++ /dev/null @@ -1,51 +0,0 @@ -{{- define "restund.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} -{{- end }} - -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "restund.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} -{{- end }} - -{{/* -Common labels -*/}} -{{- define "restund.labels" -}} -helm.sh/chart: {{ include "restund.chart" . }} -{{ include "restund.selectorLabels" . }} -{{- if .Chart.AppVersion }} -app.kubernetes.io/version: {{ .Values.image.tag | default .Chart.AppVersion | quote }} -{{- end }} -app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- end }} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -If release name contains chart name it will be used as a full name. -*/}} -{{- define "restund.fullname" -}} -{{- if .Values.fullnameOverride }} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- $name := default .Chart.Name .Values.nameOverride }} -{{- if contains $name .Release.Name }} -{{- .Release.Name | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} -{{- end }} -{{- end }} -{{- end }} - -{{- define "restund.selectorLabels" -}} -app.kubernetes.io/name: {{ include "restund.name" . }} -app.kubernetes.io/instance: {{ .Release.Name }} -{{- end }} - -{{- define "restund.federateCAName" -}} -{{- $nameParts := list (include "restund.fullname" .) -}} -{{- $nameParts = append $nameParts "federate-ca-name" -}} -{{- join "-" $nameParts -}} -{{- end }} diff --git a/charts/restund/templates/ca-configmap.yaml b/charts/restund/templates/ca-configmap.yaml deleted file mode 100644 index 0e0dd8d5bed..00000000000 --- a/charts/restund/templates/ca-configmap.yaml +++ /dev/null @@ -1,9 +0,0 @@ -{{- if .Values.federate.dtls.enabled }} -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ include "restund.federateCAName" . }} -data: - CA: - {{ .Values.federate.dtls.ca | quote }} -{{- end }} diff --git a/charts/restund/templates/configmap-restund-conf-template.yaml b/charts/restund/templates/configmap-restund-conf-template.yaml deleted file mode 100644 index d65fbfc6930..00000000000 --- a/charts/restund/templates/configmap-restund-conf-template.yaml +++ /dev/null @@ -1,62 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ include "restund.fullname" . }} - labels: - {{- include "restund.selectorLabels" . | nindent 4 }} - -data: - restund.conf.template: | - ## core - daemon no - debug no - realm dummy.io - syncinterval 600 - udp_listen ${RESTUND_HOST}:{{ .Values.restundUDPListenPort }} - udp_sockbuf_size 524288 - tcp_listen ${RESTUND_HOST}:{{ .Values.restundTCPListenPort }} - # tls_listen - - ## modules - module_path /usr/local/lib/restund/modules - module stat.so - module drain.so - module binding.so - module auth.so - module turn.so - module zrest.so - module status.so - - ## auth - auth_nonce_expiry 3600 - - ## turn - turn_max_allocations 64000 - turn_max_lifetime 3600 - turn_relay_addr ${RESTUND_HOST} - # # turn_public_addr is an IP which must be reachable for UDP traffic from other restund servers (and from this server itself). If unset, defaults to 'turn_relay_addr' - # turn_public_addr - - # syslog - syslog_facility 24 - - ## status - status_http_addr ${POD_IP} - status_http_port {{ .Values.restundHTTPStatusPort }} - # status_udp_addr - # status_udp_port - - # zrest - zrest_listen ${POD_IP} - zrest_secret ${ZREST_SECRET} - -{{- if .Values.federate.enabled }} - # federate - federate_listen ${RESTUND_HOST} - federate_port {{ .Values.federate.port }} - federate_type dtls -{{- if .Values.federate.dtls.enabled }} - federate_certfile /home/restund/federate-cert+key.pem - federate_cafile /home/restund/federate-ca-certs.pem -{{- end }} -{{- end }} diff --git a/charts/restund/templates/secret-or-certificate.yaml b/charts/restund/templates/secret-or-certificate.yaml deleted file mode 100644 index 4e2914013dc..00000000000 --- a/charts/restund/templates/secret-or-certificate.yaml +++ /dev/null @@ -1,41 +0,0 @@ -{{- if .Values.federate.dtls.enabled -}} - -{{- if .Values.federate.dtls.tls.issuerRef -}} -{{- if or .Values.federate.dtls.tls.key .Values.federate.dtls.tls.crt }} -{{- fail "issuerRef and {crt,key} are mutually exclusive" -}} -{{- end -}} -apiVersion: cert-manager.io/v1 -kind: Certificate -metadata: - name: "{{ include "restund.fullname" . }}" - labels: - {{- include "restund.labels" . | nindent 4 }} - {{- if .Values.federate.dtls.tls.certificate.labels }} - {{- toYaml .Values.federate.dtls.tls.certificate.labels | nindent 4}} - {{- end }} -spec: - dnsNames: - {{- toYaml .Values.federate.dtls.tls.certificate.dnsNames | nindent 4 }} - secretName: restund-certificate - issuerRef: - {{- toYaml .Values.federate.dtls.tls.issuerRef | nindent 4 }} - privateKey: - rotationPolicy: Always - algorithm: ECDSA - size: 384 -{{- else if and .Values.federate.dtls.tls.key .Values.federate.dtls.tls.crt }} -apiVersion: v1 -kind: Secret -metadata: - name: restund-certificate - labels: - {{- include "restund.labels" . | nindent 4 }} -type: Opaque -data: - tls.key: {{ .Values.federate.dtls.tls.key | b64enc }} - tls.crt: {{ .Values.federate.dtls.tls.crt | b64enc }} -{{- else -}} -{{- fail "must specify tls.key and tls.crt , or tls.issuerRef" -}} -{{- end -}} - -{{- end -}} diff --git a/charts/restund/templates/secret.yaml b/charts/restund/templates/secret.yaml deleted file mode 100644 index f5652f9dacc..00000000000 --- a/charts/restund/templates/secret.yaml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: v1 -kind: Secret -metadata: - name: restund - labels: - chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} - release: "{{ .Release.Name }}" - heritage: "{{ .Release.Service }}" -type: Opaque -data: - zrest_secret.txt: {{ .Values.secrets.zrestSecret | b64enc | quote }} diff --git a/charts/restund/templates/service-account.yaml b/charts/restund/templates/service-account.yaml deleted file mode 100644 index 1708744dd63..00000000000 --- a/charts/restund/templates/service-account.yaml +++ /dev/null @@ -1,33 +0,0 @@ ---- -apiVersion: v1 -kind: ServiceAccount -metadata: - name: {{ include "restund.fullname" . }} - labels: - {{- include "restund.labels" . | nindent 4 }} ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: {{ include "restund.fullname" . }} - labels: - {{- include "restund.labels" . | nindent 4 }} -rules: - - apiGroups: [""] - resources: [nodes] - verbs: [get] ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - name: {{ include "restund.fullname" . }} - labels: - {{- include "restund.labels" . | nindent 4 }} -roleRef: - kind: ClusterRole - apiGroup: rbac.authorization.k8s.io - name: {{ include "restund.fullname" . }} -subjects: - - kind: ServiceAccount - name: {{ include "restund.fullname" . }} - namespace: {{ .Release.Namespace }} diff --git a/charts/restund/templates/service.yaml b/charts/restund/templates/service.yaml deleted file mode 100644 index d5f0a7b9409..00000000000 --- a/charts/restund/templates/service.yaml +++ /dev/null @@ -1,20 +0,0 @@ ---- -apiVersion: v1 -kind: Service -metadata: - name: {{ include "restund.fullname" . }} - labels: - {{- include "restund.labels" . | nindent 4 }} -spec: - # Needs to be headless - # See: https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/ - clusterIP: None - ports: - - name: restund-tcp - port: 3478 - targetPort: restund-tcp - - name: sft-config - port: 8000 - targetPort: sft-config - selector: - {{- include "restund.selectorLabels" . | nindent 4 }} diff --git a/charts/restund/templates/statefulset.yaml b/charts/restund/templates/statefulset.yaml deleted file mode 100644 index 8ae1b05f76a..00000000000 --- a/charts/restund/templates/statefulset.yaml +++ /dev/null @@ -1,163 +0,0 @@ -apiVersion: apps/v1 -kind: StatefulSet -metadata: - name: {{ include "restund.fullname" . }} - labels: - {{- include "restund.labels" . | nindent 4 }} - -spec: - replicas: {{ .Values.replicaCount }} - - # Allows restund to start up and shut down in parallel when scaling up and down. - # However this does not affect upgrades. - podManagementPolicy: Parallel - - serviceName: {{ include "restund.fullname" . }} - selector: - matchLabels: - {{- include "restund.selectorLabels" . | nindent 6 }} - template: - metadata: - {{- with .Values.podAnnotations }} - annotations: - {{- toYaml . | nindent 8 }} - {{- end }} - - labels: - {{- include "restund.selectorLabels" . | nindent 8 }} - spec: - topologySpreadConstraints: - - maxSkew: 1 - topologyKey: "kubernetes.io/hostname" - whenUnsatisfiable: ScheduleAnyway - labelSelector: - matchLabels: - {{- include "restund.selectorLabels" . | nindent 6 }} - securityContext: - {{- toYaml .Values.podSecurityContext | nindent 8 }} - hostNetwork: true - serviceAccountName: {{ include "restund.fullname" . }} - volumes: - - name: external-ip - emptyDir: {} - - name: restund-config-template - configMap: - name: {{ include "restund.fullname" . }} - - name: secrets - secret: - secretName: restund -{{- if .Values.federate.dtls.enabled }} - - name: restund-certificate - secret: - secretName: restund-certificate - - name: ca-certs - configMap: - name: {{ include "restund.federateCAName" . }} -{{- end }} - initContainers: - - name: get-external-ip - image: {{ .Values.kubectlImage.registry }}/{{ .Values.kubectlImage.repository }}:{{ .Values.kubectlImage.tag }} - volumeMounts: - - name: external-ip - mountPath: /external-ip - env: - - name: NODE_NAME - valueFrom: - fieldRef: - fieldPath: spec.nodeName - command: - - /bin/sh - - -c - - | - set -e - - # In the cloud, this setting is available to indicate the true IP address - addr=$(kubectl get node $NODE_NAME -ojsonpath='{.status.addresses[?(@.type=="ExternalIP")].address}') - - # On on-prem we allow people to set "wire.com/external-ip" to override this - if [ -z "$addr" ]; then - addr=$(kubectl get node $NODE_NAME -ojsonpath='{.metadata.annotations.wire\.com/external-ip}') - fi - echo -n "$addr" | tee /dev/stderr > /external-ip/ip - containers: - - name: {{ .Chart.Name }} - {{- if .Values.image.digest }} - image: "{{ .Values.image.repository }}@{{ .Values.image.digest }}" - {{- else }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" - {{- end }} - imagePullPolicy: {{ .Values.image.pullPolicy }} - env: - - name: POD_IP - valueFrom: - fieldRef: - fieldPath: status.podIP - - name: POD_NAME - valueFrom: - fieldRef: - fieldPath: metadata.name - volumeMounts: - - name: external-ip - mountPath: /external-ip - - name: restund-config-template - mountPath: /restund-template/restund.conf.template - subPath: restund.conf.template - - name: secrets - mountPath: /secrets/ - readOnly: true -{{- if .Values.federate.dtls.enabled }} - - name: ca-certs - mountPath: /ca-certs - - name: restund-certificate - mountPath: restund-certificate -{{- end }} - command: - - /bin/sh - - -c - - | - set -e - EXTERNAL_IP=$(cat /external-ip/ip) - export RESTUND_HOST="$EXTERNAL_IP" - export ZREST_SECRET="$(cat /secrets/zrest_secret.txt)" -{{- if .Values.federate.dtls.enabled }} - cat /restund-certificate/tls.crt /restund-certificate/tls.key > /home/restund/federate-cert+key.pem - cp /ca-certs/CA /home/restund/federate-ca-certs.pem -{{- end }} - envsubst '$RESTUND_HOST $POD_IP $ZREST_SECRET' < /restund-template/restund.conf.template > /home/restund/restund.conf - exec /usr/local/sbin/restund -n -f /home/restund/restund.conf - - ports: - - name: restund-tcp - containerPort: 3478 - protocol: TCP - - name: sft-config - containerPort: 8000 - protocol: TCP - - name: status-http - containerPort: {{ .Values.restundHTTPStatusPort }} - protocol: TCP - - livenessProbe: - httpGet: - path: / - port: status-http - - readinessProbe: - httpGet: - path: / - port: status-http - - resources: - {{- toYaml .Values.resources | nindent 12 }} - {{- with .Values.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} diff --git a/charts/restund/values.yaml b/charts/restund/values.yaml deleted file mode 100644 index e45c63670c2..00000000000 --- a/charts/restund/values.yaml +++ /dev/null @@ -1,74 +0,0 @@ -# The amount of Restund instances to run. NOTE: Only one Restund can run per node due -# to `hostNetwork`. If this number is higher than the amount of nodes that can -# be used for scheduling (Also see `nodeSelector`) pods will remain in a -# pending state untill you add more capacity. -replicaCount: 1 - -image: - repository: quay.io/wire/restund - pullPolicy: Always - # overwrite the tag here, otherwise `appVersion` of the chart will be used - tag: "" - -kubectlImage: - # Use a kubectl image that includes a shell (sh/bash). Distroless images will fail to exec the script. - registry: docker.io - repository: bitnamilegacy/kubectl - tag: 1.32.4 - -# If you have multiple deployments of Restund running in one cluster, it is -# important that they run on disjoint sets of nodes, you can use nodeSelector to enforce this -nodeSelector: {} - -podSecurityContext: - fsGroup: 31337 - -securityContext: - # Pick a high number that is unlikely to conflict with the host - # https://kubesec.io/basics/containers-securitycontext-runasuser/ - runAsUser: 31337 - -restundUDPListenPort: 3478 -restundTCPListenPort: 3478 -restundUDPStatusPort: 33000 -restundHTTPStatusPort: 8080 -restundMetricsListenPort: 8443 - -federate: - enabled: false - port: 9191 - - dtls: - enabled: true - - tls: - # Example: - # - # tls: - # key: "-----BEGIN EC PRIVATE KEY----- ..." # (ascii blob) private key - # crt: "-----BEGIN CERTIFICATE----- ..." # (ascii blob) certificate - # - # OR (mutually exclusive) - # - # tls: - # issuerRef: - # name: letsencrypt-http01 - # - # # We can reference ClusterIssuers by changing the kind here. - # # The default value is Issuer (i.e. a locally namespaced Issuer) - # # kind: Issuer - # kind: Issuer - # - # # This is optional since cert-manager will default to this value however - # # if you are using an external issuer, change this to that issuer group. - # group: cert-manager.io - # - # # optional labels to attach to the cert-manager Certificate - # certificate: - # labels: .. - # - # host: # public hostname for which the certificate is created for. - # - ca: # list of trusted CA certificates (concatenated list of PEMs) - # example: - # ca: "-----BEGIN CERTIFICATE-----" diff --git a/docs/src/how-to/install/sft.md b/docs/src/how-to/install/sft.md index 1432d76da68..a2d18cb7a23 100644 --- a/docs/src/how-to/install/sft.md +++ b/docs/src/how-to/install/sft.md @@ -82,10 +82,10 @@ For more advanced setups please refer to the [technical documentation](https://g The SFT allocates media addresses in the UDP [default port range](../../understand/notes/port-ranges.md#port-ranges). Ingress and egress traffic should be allowed for this range. Furthermore the SFT needs to be -able to reach the [Restund server](../../understand/restund.md#understand-restund), as it uses STUN and TURN in cases the client +able to reach the Coturn (or previously [Restund server](../../understand/restund.md#understand-restund)), as it uses STUN and TURN in cases the client can not directly connect to the SFT. In practise this means the SFT should allow ingress and egress traffic on the UDP [default port range](../../understand/notes/port-ranges.md#port-ranges) from and -to both, clients and [Restund servers](../../understand/restund.md#understand-restund). +to both, clients and Coturn (or previously [Restund servers](../../understand/restund.md#understand-restund)). *For more information on this port range, how to read and change it, and how to configure your firewall, please see* [this note](../../understand/notes/port-ranges.md#port-ranges). diff --git a/docs/src/how-to/install/troubleshooting.md b/docs/src/how-to/install/troubleshooting.md index aacf3e9cbab..ecb0ffb636a 100644 --- a/docs/src/how-to/install/troubleshooting.md +++ b/docs/src/how-to/install/troubleshooting.md @@ -433,8 +433,8 @@ From your own computer (not from the Wire backend), test that you can reach all * `nginz-https.` * `nginz-ssl.` * `sftd.` -* `restund01.` -* `restund02.` +* `turn01.` +* `turn02.` * `federator.` Some domains (such as the federator) might not apply to your setup. Refer to the domains you configured during installation, and act accordingly. diff --git a/nix/local-haskell-packages.nix b/nix/local-haskell-packages.nix index 55e76a1ea18..c1cc9ce6a3e 100644 --- a/nix/local-haskell-packages.nix +++ b/nix/local-haskell-packages.nix @@ -59,7 +59,6 @@ entreprise-provisioning = hself.callPackage ../tools/entreprise-provisioning/default.nix { inherit gitignoreSource; }; mlsstats = hself.callPackage ../tools/mlsstats/default.nix { inherit gitignoreSource; }; rabbitmq-consumer = hself.callPackage ../tools/rabbitmq-consumer/default.nix { inherit gitignoreSource; }; - rex = hself.callPackage ../tools/rex/default.nix { inherit gitignoreSource; }; stern = hself.callPackage ../tools/stern/default.nix { inherit gitignoreSource; }; test-stats = hself.callPackage ../tools/test-stats/default.nix { inherit gitignoreSource; }; } diff --git a/services/restund/.gitignore b/services/restund/.gitignore deleted file mode 100644 index 4c6028d6684..00000000000 --- a/services/restund/.gitignore +++ /dev/null @@ -1,29 +0,0 @@ -# Object files -*.o - -# Libraries -*.lib -*.a - -# Shared objects (inc. Windows DLLs) -*.dll -*.so -*.dylib - -# Executables -*.exe -*.out -*.app - -# All them temporary directories and files -install -packages -src -target -.*.swp -dist -*.aci* -*.log -.vagrant -*.docker - diff --git a/services/restund/Dockerfile b/services/restund/Dockerfile deleted file mode 100644 index 4e500ae960c..00000000000 --- a/services/restund/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ -FROM ubuntu:16.04 - -ARG re_version -ARG restund_version -ARG extra_modules="zrest drain" -ARG DEBIAN_FRONTEND=noninteractive - -COPY src /build -RUN apt-get update \ - && apt-get install -y make gcc libssl-dev \ - && cd /build/re-${re_version} \ - && make RELEASE=1 \ - && make RELEASE=1 PREFIX=/usr/local install \ - && cd /build/restund-${restund_version} \ - && make RELEASE=1 EXTRA_CFLAGS="-std=gnu99" EXTRA_MODULES='${extra_modules}' \ - && make RELEASE=1 EXTRA_MODULES='${extra_modules}' PREFIX=/usr/local install \ - && ldconfig \ - && rm -rf /build \ - && apt-get remove -y make gcc \ - && apt-get autoremove -y - -RUN useradd --system --shell /bin/false -U restund - -USER restund -VOLUME /usr/local/etc/restund -#EXPOSE 1024-65000 -ENTRYPOINT ["/usr/local/sbin/restund", "-n", "-f", "/usr/local/etc/restund/restund.conf" ] diff --git a/services/restund/LICENSE b/services/restund/LICENSE deleted file mode 100644 index dba13ed2ddf..00000000000 --- a/services/restund/LICENSE +++ /dev/null @@ -1,661 +0,0 @@ - GNU AFFERO GENERAL PUBLIC LICENSE - Version 3, 19 November 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU Affero General Public License is a free, copyleft license for -software and other kinds of works, specifically designed to ensure -cooperation with the community in the case of network server software. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -our General Public Licenses are intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - Developers that use our General Public Licenses protect your rights -with two steps: (1) assert copyright on the software, and (2) offer -you this License which gives you legal permission to copy, distribute -and/or modify the software. - - A secondary benefit of defending all users' freedom is that -improvements made in alternate versions of the program, if they -receive widespread use, become available for other developers to -incorporate. Many developers of free software are heartened and -encouraged by the resulting cooperation. However, in the case of -software used on network servers, this result may fail to come about. -The GNU General Public License permits making a modified version and -letting the public access it on a server without ever releasing its -source code to the public. - - The GNU Affero General Public License is designed specifically to -ensure that, in such cases, the modified source code becomes available -to the community. It requires the operator of a network server to -provide the source code of the modified version running there to the -users of that server. Therefore, public use of a modified version, on -a publicly accessible server, gives the public access to the source -code of the modified version. - - An older license, called the Affero General Public License and -published by Affero, was designed to accomplish similar goals. This is -a different license, not a version of the Affero GPL, but Affero has -released a new version of the Affero GPL which permits relicensing under -this license. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU Affero General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Remote Network Interaction; Use with the GNU General Public License. - - Notwithstanding any other provision of this License, if you modify the -Program, your modified version must prominently offer all users -interacting with it remotely through a computer network (if your version -supports such interaction) an opportunity to receive the Corresponding -Source of your version by providing access to the Corresponding Source -from a network server at no charge, through some standard or customary -means of facilitating copying of software. This Corresponding Source -shall include the Corresponding Source for any work covered by version 3 -of the GNU General Public License that is incorporated pursuant to the -following paragraph. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the work with which it is combined will remain governed by version -3 of the GNU General Public License. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU Affero General Public License from time to time. Such new versions -will be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU Affero General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU Affero General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU Affero General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If your software can interact with users remotely through a computer -network, you should also make sure that it provides a way for users to -get its source. For example, if your program is a web application, its -interface could display a "Source" link that leads users to an archive -of the code. There are many ways you could offer source, and different -solutions will be better for different programs; see section 13 for the -specific requirements. - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU AGPL, see -. diff --git a/services/restund/Makefile b/services/restund/Makefile deleted file mode 100644 index adedad7ce93..00000000000 --- a/services/restund/Makefile +++ /dev/null @@ -1,112 +0,0 @@ -LANG := en_US.UTF-8 -SHELL := /usr/bin/env bash - -BUILD_NUMBER ?= 0 - -RE_VERSION := 0.4.15 -RE_TARBALL := re-$(RE_VERSION).tar.gz -RE_SRC := src/re-$(RE_VERSION)/Makefile -RE_URL := https://github.com/creytiv/re/archive - -RESTUND_VERSION := 0.4.14 -RESTUND_TARBALL := restund-$(RESTUND_VERSION).tar.gz -RESTUND_SRC := src/restund-$(RESTUND_VERSION)/Makefile -RESTUND_URL := https://github.com/wireapp/restund/archive - -WIRE_VERSION := 7 - -EXTRA_MODULES := zrest drain - -DOCKER ?= true -DOCKER_USER ?= quay.io/wire -IMAGE_VERSION := $(RESTUND_VERSION)w$(WIRE_VERSION)b$(BUILD_NUMBER) -ACI := restund-$(IMAGE_VERSION)_linux_amd64.aci - -ACI_PORTS := udp,protocol=udp,port=1024,count=64411,socketActivated=false -ACI_PORTS += tcp,protocol=tcp,port=3478,count=1,socketActivated=false -ACI_PORTS += tls,protocol=tcp,port=5349,count=1,socketActivated=false -ACI_PORTS += http,protocol=tcp,port=8080,count=1,socketActivated=false - -space := $() $() - - -default: dist - -.PHONY: dist -dist: clean $(ACI) - -.PHONY: build -ifeq ($(DOCKER),true) -build: build-docker -else -build: $(RESTUND_SRC) $(RE_SRC) extra_modules - $(MAKE) -C src/re-$(RE_VERSION) RELEASE=1 - $(MAKE) -C src/re-$(RE_VERSION) PREFIX=/usr/local install - $(MAKE) -C src/restund-$(RESTUND_VERSION) RELEASE=1 EXTRA_MODULES='$(EXTRA_MODULES)' - $(MAKE) -C src/restund-$(RESTUND_VERSION) RELEASE=1 EXTRA_MODULES='$(EXTRA_MODULES)' PREFIX=/usr/local install - ldconfig -endif - -.PHONY: image -image: $(ACI) - -.PHONY: publish -publish: $(ACI) $(ACI).asc - -.PHONY: clean -clean: - rm -rf src - rm -f *.docker *.aci *.asc - -%.asc: - gpg --armor --yes --output $*.asc --detach-sig $* - -.PHONY: concourse -concourse: $(RESTUND_SRC) $(RE_SRC) extra_modules - printf '{"re_version":"%s","restund_version":"%s"}\n' \ - $(RE_VERSION) $(RESTUND_VERSION) > build_args.json - echo $(IMAGE_VERSION) > tag.txt - -.PHONY: build-docker -build-docker: $(RESTUND_SRC) $(RE_SRC) extra_modules - docker build -t $(DOCKER_USER)/restund:$(IMAGE_VERSION) \ - --build-arg re_version=$(RE_VERSION) \ - --build-arg restund_version=$(RESTUND_VERSION) \ - --build-arg extra_modules="$(EXTRA_MODULES)" \ - . - -$(ACI): build-docker - docker save -o restund-$(IMAGE_VERSION).docker \ - $(DOCKER_USER)/restund:$(IMAGE_VERSION) - docker2aci -debug restund-$(IMAGE_VERSION).docker - actool -debug patch-manifest -overwrite \ - --ports='$(subst $(space),:,$(ACI_PORTS))' \ - restund-$(IMAGE_VERSION).aci $(ACI) - rm restund-$(IMAGE_VERSION).aci restund-$(IMAGE_VERSION).docker - -packages: - mkdir -p packages - -packages/$(RE_TARBALL): packages - curl -sSLf $(RE_URL)/v$(RE_VERSION).tar.gz -o packages/$(RE_TARBALL) - -packages/$(RESTUND_TARBALL): packages - curl -sSLf $(RESTUND_URL)/v$(RESTUND_VERSION).tar.gz -o packages/$(RESTUND_TARBALL) - -.PHONY: tarballs -tarballs: packages/$(RE_TARBALL) packages/$(RESTUND_TARBALL) - -src: - mkdir -p src - -$(RE_SRC): packages/$(RE_TARBALL) | src - tar -C src -xmvf $(CURDIR)/packages/$(RE_TARBALL) - -$(RESTUND_SRC): packages/$(RESTUND_TARBALL) | src - tar -C src -xmvf $(CURDIR)/packages/$(RESTUND_TARBALL) - -src/restund-$(RESTUND_VERSION)/modules/%: $(RESTUND_SRC) - cp -r $(CURDIR)/modules/$* src/restund-$(RESTUND_VERSION)/modules - -.PHONY: extra_modules -extra_modules: $(addprefix src/restund-$(RESTUND_VERSION)/modules/,$(EXTRA_MODULES)) diff --git a/services/restund/README.md b/services/restund/README.md deleted file mode 100644 index 1cab623bb4f..00000000000 --- a/services/restund/README.md +++ /dev/null @@ -1,154 +0,0 @@ -# Restund - -`restund` is used for audio and video calls. - -This folder contains extra modules on top of [restund](https://github.com/wireapp/restund), as well as some build instructions. - -## License - -* The actual [restund](https://github.com/wireapp/restund) is under [BSD](https://github.com/wireapp/restund/blob/master/docs/COPYING) -* This folder's extra modules, like the rest of wire-server, are under AGPL, see [LICENSE](LICENSE) - -## Building - -The preferred way of building `restund` is via Docker, which -encodes all build- and runtime dependencies. The only prerequisites on the build -machine are thus `docker` and `make`. - -```shell -make build -``` - -It's possible to bypass `docker`, in which case the host must have all -build-time dependencies installed. - -```shell -make build DOCKER=false -``` - -## Creating ACIs for use with rkt - -If you'd like to create an [ACI](https://github.com/appc/spec/blob/master/spec/aci.md) for use with [rkt](https://github.com/rkt/rkt), -apart from`docker` and `make`, you'll need [docker2aci](https://github.com/appc/docker2aci) and -[actool](https://github.com/appc/spec/tree/master/actool) installed on the build -machine. This also implies having the Go language toolchain installed, unless -you can get hold of the binaries by some other means. Additionally, `gpg` needs to be installed and set -up in order to create signatures for the ACIs. - -```shell -export PATH=$GOPATH/bin:$PATH -go get -u github.com/appc/docker2aci -go get -u github.com/appc/spec/actool -``` - -> Note: the versions used as of this writing are: -> -> ```shell -> local:~$ docker2aci --version -> docker2aci version 0.16.0+git -> appc version 0.8.10 -> local:~$ actool version -> actool version 0.8.10+git -> ``` -> -> You may want to upgrade these tools from time to time by re-executing -> the above `go get` commands. - -Create an `.aci` and signature: - -```shell -make publish -``` - -Before releasing, you may want to increment the version(s): `restund` is -versioned according to its upstream version, plus a "wire version" set in the -Makefile. - -## Running restund on a server - -You need - -* the aci image built in the section above, or, alternatively, a natively compiled `restund` binary with all the shared libraries available. -* an adapted restund config (see below) -* (optionally) a TLS certificate chain in PEM format, including the private key - -Example config file: - -```conf -# /etc/restund/restund.conf - -# core -daemon no -debug no -realm dummy.io -syncinterval 600 -udp_listen {{ ansible_default_ipv4.address }}:3478 -udp_sockbuf_size 524288 -tcp_listen {{ ansible_default_ipv4.address }}:3478 -# tls_listen is optional, you can comment that line out. If set, you must provide a valid TLS certificate for the domain name you're advertising. -# tls_listen {{ ansible_default_ipv4.address }}:5349,/usr/local/etc/restund/restund.pem - -# modules -module_path /usr/local/lib/restund/modules -module stat.so -module drain.so -module binding.so -module turn.so -module status.so -# The auth and zrest modules are optional. If enabled, ensure the zrest_secret below is set to a value shared with the configuration in brig. -module zrest.so -module auth.so - -# auth -auth_nonce_expiry 3600 - -# turn -turn_max_allocations 64000 -turn_max_lifetime 3600 -turn_relay_addr {{ ansible_default_ipv4.address }} - -# You generally don't need to set this (only if your server is on a private network and must be reachable from other restund servers that are on another network): -# turn_public_addr is an IP which must be reachable for UDP traffic from other restund servers (and from this server itself). If unset, defaults to 'turn_relay_addr' -#turn_public_addr {{ public_ipv4 }} - -# syslog -syslog_facility 24 - -# status -status_udp_addr 127.0.0.1 -status_udp_port 33000 -status_http_addr 127.0.0.1 -status_http_port 8080 - -# zrest (shared secret shared with brig, optional) -zrest_secret {{ restund_zrest_secret }} -``` - -Adjust the above configuration: - -* Replace the `{{ variables }}` with real values (without `{{`)): - * Put your private IP of the server in place of: `{{ ansible_default_ipv4.address }}`. -* You may comment these out in case you don't want to use authentication: -``` -module zrest.so -module auth.so -zrest_secret {{ restund_zrest_secret }} -``` - - -Next, list out TURN IP and port in `services/brig/test/resources/turn/servers.txt`, and `services/brig/test/resources/turn/servers-v2.txt`, as given below: -`turn::3478` -Then run the command restund command and you'll get the live stun log in your terminal. - -Running restund with `rkt`: - -``` -/usr/bin/rkt run \ - --net=host \ - --dns=host \ - --hosts-entry=host \ - --volume volume-usr-local-etc-restund,kind=host,source=/etc/restund,readOnly=true \ - {{ aci_base_url }}/restund/restund-{{ versions.restund }}_linux_amd64.aci \ - --user=restund \ - --group=restund -``` diff --git a/services/restund/modules/drain/drain.c b/services/restund/modules/drain/drain.c deleted file mode 100644 index 7e082fe478a..00000000000 --- a/services/restund/modules/drain/drain.c +++ /dev/null @@ -1,144 +0,0 @@ -/** - * @file drain.c - * - * Copyright (c) 2018 Wire Swiss GmbH - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#include -#include - - -static bool is_draining = false; - -/* - * Iff is_draining == true, prevents new allocations and denies allocation - * refresh by replying with a '508 Insufficient Capacity' message. - */ -static bool request_handler(struct restund_msgctx *ctx, int proto, void *sock, - const struct sa *src, const struct sa *dst, - const struct stun_msg *msg) -{ - int err; - struct stun_attr *lt; - - if (is_draining) { - switch (stun_msg_method(msg)) { - - case STUN_METHOD_ALLOCATE: - restund_info("received ALLOCATE request while in drain mode\n"); - goto unavailable; - - case STUN_METHOD_REFRESH: - lt = stun_msg_attr(msg, STUN_ATTR_LIFETIME); - - if (lt && lt->v.lifetime > 0) { - restund_info("received REFRESH request while in drain mode\n"); - goto unavailable; - } - - break; - - default: - break; - } - } - - return false; - - unavailable: - err = stun_ereply(proto, sock, src, 0, msg, - 508, "Draining", - NULL, 0, ctx->fp, 1, - STUN_ATTR_SOFTWARE, restund_software); - - if (err) { - restund_warning("drain reply error: %m\n", err); - } - - return true; -} - -static struct restund_stun stun = { - .reqh = request_handler -}; - -// commands - -static void drain_print(struct mbuf *mb) -{ - (void)mbuf_printf(mb, "is_draining: %d\n", is_draining); -} - -static void drain_enable(struct mbuf *mb) -{ - is_draining = true; - drain_print(mb); -} - -static void drain_disable(struct mbuf *mb) -{ - is_draining = false; - drain_print(mb); -} - -static struct restund_cmdsub cmd_drain_print = { - .cmdh = drain_print, - .cmd = "drain_state", -}; - -static struct restund_cmdsub cmd_drain_enable = { - .cmdh = drain_enable, - .cmd = "drain_enable", -}; - -static struct restund_cmdsub cmd_drain_disable = { - .cmdh = drain_disable, - .cmd = "drain_disable", -}; - - -// module - -static int module_init(void) -{ - restund_stun_register_handler(&stun); - restund_cmd_subscribe(&cmd_drain_print); - restund_cmd_subscribe(&cmd_drain_enable); - restund_cmd_subscribe(&cmd_drain_disable); - - restund_debug("drain: module loaded\n"); - - return 0; -} - -static int module_close(void) -{ - restund_cmd_unsubscribe(&cmd_drain_enable); - restund_cmd_unsubscribe(&cmd_drain_disable); - restund_cmd_unsubscribe(&cmd_drain_print); - restund_stun_unregister_handler(&stun); - - restund_debug("drain: module closed\n"); - - return 0; -} - -const struct mod_export DECL_EXPORTS(drain) = { - .name = "drain", - .type = "stun", - .init = module_init, - .close = module_close, -}; diff --git a/services/restund/modules/drain/module.mk b/services/restund/modules/drain/module.mk deleted file mode 100644 index 940cfd05cb8..00000000000 --- a/services/restund/modules/drain/module.mk +++ /dev/null @@ -1,23 +0,0 @@ -# -# module.mk -# -# Copyright (c) 2018 Wire Swiss GmbH -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. - -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -MOD := drain -$(MOD)_SRCS += drain.c -$(MOD)_LFLAGS += - -include mk/mod.mk diff --git a/services/restund/modules/zrest/module.mk b/services/restund/modules/zrest/module.mk deleted file mode 100644 index 1f65af5a364..00000000000 --- a/services/restund/modules/zrest/module.mk +++ /dev/null @@ -1,23 +0,0 @@ -# -# module.mk -# -# Copyright (c) 2018 Wire Swiss GmbH -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. - -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -MOD := zrest -$(MOD)_SRCS += zrest.c -$(MOD)_LFLAGS += - -include mk/mod.mk diff --git a/services/restund/modules/zrest/zrest.c b/services/restund/modules/zrest/zrest.c deleted file mode 100644 index 66ce8a47a9d..00000000000 --- a/services/restund/modules/zrest/zrest.c +++ /dev/null @@ -1,283 +0,0 @@ -/** - * @file zrest.c Zeta REST-based authentication - * - * Copyright (c) 2018 Wire Swiss GmbH - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#include -#include -#include -#include -#include -#include -#include - - -/* - * This module implements a REST-based authentication mechanism - * using ephemeral (i.e. time-limited) credentials. - * - * A shared secret must be configured in the config file, and can then - * be shared with a HTTP REST-based service. - * - * Format: - * - * username = .s. - * password = HMAC_SHA512(secret, username) - */ - - -static struct { - char secret[256]; - size_t secret_len; - - struct http_sock *http_sock; /* optional */ -} zrest; - - -#if 0 -static void generate_username_v0(char *user, size_t sz, uint32_t ttl) -{ - char x[42]; - time_t now = time(NULL); - - rand_str(x, sizeof(x)); - - re_snprintf(user, sz, - "%llu.s.%s", (uint64_t)(now + ttl), x); -} -#endif - - -static void generate_username_v1(char *user, size_t sz, uint32_t ttl) -{ - char x[42]; - time_t now = time(NULL); - - rand_str(x, sizeof(x)); - - re_snprintf(user, sz, - "d=%llu.v=1.k=0.t=s.r=%s", - (uint64_t)(now + ttl), x); -} - - -static int generate_password(char *pass, size_t *passlen, const char *user) -{ - uint8_t digest[SHA512_DIGEST_LENGTH]; - unsigned int md_len = sizeof(digest); - int err; - - if (!HMAC(EVP_sha512(), - zrest.secret, (int)zrest.secret_len, - (void *)user, (int)strlen(user), - digest, &md_len)) { - - restund_warning("zrest: HMAC failed\n"); - ERR_clear_error(); - return EINVAL; - } - - err = base64_encode(digest, sizeof(digest), pass, passlen); - if (err) - return err; - - return 0; -} - - -static int auth_handler(const char *user, uint8_t *ha1) -{ - struct pl expires; - time_t expi; - char pass[256]; - size_t passlen = sizeof(pass); - struct pl pl_keyindex; - uint32_t keyindex = 0; - int err; - - if (0 == re_regex(user, strlen(user), - "d=[0-9]+.v=1.k=[0-9]+.t=s.r=[a-z0-9]*", - &expires, &pl_keyindex, NULL)) { - - keyindex = pl_u32(&pl_keyindex); - - restund_debug("zrest: auth version 1 (keyindex=%u)\n", - keyindex); - } - else if (0 == re_regex(user, strlen(user), - "[0-9]+.s.[0-9]*", &expires, NULL)) { - - restund_info("zrest: auth version 0\n"); - } - else { - restund_info("zrest: could not parse username (%s)\n", user); - return EPROTO; - } - - expi = (time_t)pl_u64(&expires); - if (expi < time(NULL)) { - restund_debug("zrest: username expired %lli seconds ago\n", - time(NULL) - pl_u64(&expires)); - return ETIMEDOUT; - } - - err = generate_password(pass, &passlen, user); - if (err) { - restund_warning("zrest: failed to generated password (%m)\n", - err); - return err; - } - - restund_debug("zrest: VALID username token :)\n"); - - return md5_printf(ha1, "%s:%s:%b", - user, restund_realm(), pass, passlen); -} - - -static void http_req_handler(struct http_conn *conn, - const struct http_msg *msg, void *arg) -{ - struct pl username; - char tsuser[256]; - uint32_t ttl = 86400; - char pass[256]; - size_t passlen = sizeof(pass); - int err; - (void)arg; - struct sa stun_addr; - - if (re_regex(msg->prm.p, msg->prm.l, "username=[^&]+", &username)) { - - restund_warning("zrest: missing username parameter\n"); - http_ereply(conn, 400, "Bad Request"); - return; - } - - generate_username_v1(tsuser, sizeof(tsuser), ttl); - - err = generate_password(pass, &passlen, tsuser); - if (err) { - restund_warning("zrest: could not generate password" - " for use '%s' (%m)\n", tsuser, err); - http_ereply(conn, 500, "Server Error"); - } - - restund_udp_socket(&stun_addr, NULL, false, false); - - http_creply(conn, 200, "OK", "application/json", - - "{\r\n" - " \"username\" : \"%s\",\r\n" - " \"password\" : \"%b\",\r\n" - " \"ttl\" : %u,\r\n" - " \"uris\" : [\r\n" - " \"turn:%J?transport=udp\",\r\n" - " ]\r\n" - "}\r\n" - , - tsuser, - pass, passlen, - ttl, - &stun_addr - ); -} - - -static int module_init(void) -{ - char addr[64]; - int err; - - err = conf_get_str(restund_conf(), "zrest_secret", zrest.secret, - sizeof(zrest.secret)); - if (err) { - restund_error("zrest: missing config 'rest_secret'\n"); - return err; - } - - zrest.secret_len = strlen(zrest.secret); - if (zrest.secret_len == 0) { - restund_error("zrest: config 'zrest_secret' is empty\n"); - return EINVAL; - } - - restund_db_set_auth_handler(auth_handler); - - /* selftest */ - if (1) { - char user[256], pass[256]; - size_t passlen = sizeof(pass); - generate_username_v1(user, sizeof(user), 60); - err = generate_password(pass, &passlen, user); - if (err) { - restund_error("zrest: failed to generate password" - " for user='%s' (%m)\n", user, err); - return err; - } - - restund_info("zrest: selftest passed (pass=%b)\n", - pass, passlen); - } - - if (0 == conf_get_str(restund_conf(), "zrest_listen", - addr, sizeof(addr))) { - - struct sa http_addr; - - err = sa_set_str(&http_addr, addr, 8000); - if (err) { - restund_warning("zrest: invalid address (%s)\n", addr); - return err; - } - - err = http_listen(&zrest.http_sock, &http_addr, - http_req_handler, NULL); - if (err) { - restund_warning("zrest: failed to listen on %J (%m)\n", - &http_addr, err); - return err; - } - - restund_info("zrest: HTTP server listening on %J\n", - &http_addr); - } - - restund_debug("zrest: module loaded\n"); - - return 0; -} - - -static int module_close(void) -{ - zrest.http_sock = mem_deref(zrest.http_sock); - - restund_db_set_auth_handler(NULL); - - restund_debug("zrest: module closed\n"); - - return 0; -} - - -const struct mod_export exports = { - .name = "zrest", - .type = "auth", - .init = module_init, - .close = module_close -}; diff --git a/tools/rex/.ormolu b/tools/rex/.ormolu deleted file mode 120000 index 157b212d7cd..00000000000 --- a/tools/rex/.ormolu +++ /dev/null @@ -1 +0,0 @@ -../../.ormolu \ No newline at end of file diff --git a/tools/rex/LICENSE b/tools/rex/LICENSE deleted file mode 100644 index dba13ed2ddf..00000000000 --- a/tools/rex/LICENSE +++ /dev/null @@ -1,661 +0,0 @@ - GNU AFFERO GENERAL PUBLIC LICENSE - Version 3, 19 November 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU Affero General Public License is a free, copyleft license for -software and other kinds of works, specifically designed to ensure -cooperation with the community in the case of network server software. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -our General Public Licenses are intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - Developers that use our General Public Licenses protect your rights -with two steps: (1) assert copyright on the software, and (2) offer -you this License which gives you legal permission to copy, distribute -and/or modify the software. - - A secondary benefit of defending all users' freedom is that -improvements made in alternate versions of the program, if they -receive widespread use, become available for other developers to -incorporate. Many developers of free software are heartened and -encouraged by the resulting cooperation. However, in the case of -software used on network servers, this result may fail to come about. -The GNU General Public License permits making a modified version and -letting the public access it on a server without ever releasing its -source code to the public. - - The GNU Affero General Public License is designed specifically to -ensure that, in such cases, the modified source code becomes available -to the community. It requires the operator of a network server to -provide the source code of the modified version running there to the -users of that server. Therefore, public use of a modified version, on -a publicly accessible server, gives the public access to the source -code of the modified version. - - An older license, called the Affero General Public License and -published by Affero, was designed to accomplish similar goals. This is -a different license, not a version of the Affero GPL, but Affero has -released a new version of the Affero GPL which permits relicensing under -this license. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU Affero General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Remote Network Interaction; Use with the GNU General Public License. - - Notwithstanding any other provision of this License, if you modify the -Program, your modified version must prominently offer all users -interacting with it remotely through a computer network (if your version -supports such interaction) an opportunity to receive the Corresponding -Source of your version by providing access to the Corresponding Source -from a network server at no charge, through some standard or customary -means of facilitating copying of software. This Corresponding Source -shall include the Corresponding Source for any work covered by version 3 -of the GNU General Public License that is incorporated pursuant to the -following paragraph. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the work with which it is combined will remain governed by version -3 of the GNU General Public License. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU Affero General Public License from time to time. Such new versions -will be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU Affero General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU Affero General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU Affero General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If your software can interact with users remotely through a computer -network, you should also make sure that it provides a way for users to -get its source. For example, if your program is a web application, its -interface could display a "Source" link that leads users to an archive -of the code. There are many ways you could offer source, and different -solutions will be better for different programs; see section 13 for the -specific requirements. - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU AGPL, see -. diff --git a/tools/rex/Main.hs b/tools/rex/Main.hs deleted file mode 100644 index 34401a8037e..00000000000 --- a/tools/rex/Main.hs +++ /dev/null @@ -1,376 +0,0 @@ -{-# LANGUAGE BangPatterns #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE RecordWildCards #-} -{-# LANGUAGE TupleSections #-} -{-# OPTIONS_GHC -Wno-incomplete-patterns #-} -{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} - -{-# HLINT ignore "Use shutdown" #-} - --- This file is part of the Wire Server implementation. --- --- Copyright (C) 2022 Wire Swiss GmbH --- --- This program is free software: you can redistribute it and/or modify it under --- the terms of the GNU Affero General Public License as published by the Free --- Software Foundation, either version 3 of the License, or (at your option) any --- later version. --- --- This program is distributed in the hope that it will be useful, but WITHOUT --- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS --- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more --- details. --- --- You should have received a copy of the GNU Affero General Public License along --- with this program. If not, see . - -module Main (main) where - -import Control.Concurrent.Async -import Control.Monad.Catch -import Control.Monad.Trans -import qualified Data.Attoparsec.ByteString.Char8 as Parser -import Data.Bifunctor -import Data.Bitraversable -import Data.ByteString (ByteString) -import qualified Data.ByteString.Char8 as ByteString -import Data.Foldable -import Data.Functor (($>)) -import Data.HashMap.Strict (HashMap) -import qualified Data.HashMap.Strict as HashMap -import Data.IP -import Data.Maybe -import Data.Text (Text) -import qualified Data.Text as Text -import Data.Text.Encoding (decodeUtf8, encodeUtf8) -import qualified Data.Text.IO as Text -import qualified Data.Text.Read as Text -import Data.Traversable -import Data.Word -import Network.DNS hiding (header) -import Network.HTTP.Types -import Network.Socket -import Network.Socket.ByteString -import Network.Wai -import Network.Wai.Handler.Warp -import Options.Applicative -import System.Clock -import qualified System.Logger as Log -import System.Logger.Message (msg, val) -import System.Metrics.Prometheus.Concurrent.RegistryT -- this library sucks -import System.Metrics.Prometheus.Encode.Text -import qualified System.Metrics.Prometheus.Metric.Counter as Counter -import System.Metrics.Prometheus.Metric.Gauge (Gauge) -import qualified System.Metrics.Prometheus.Metric.Gauge as Gauge -import qualified System.Metrics.Prometheus.Metric.Histogram as Histo -import System.Metrics.Prometheus.MetricId -import System.Metrics.Prometheus.Registry (RegistrySample) -import System.Timeout (timeout) - -data Opts = Opts - { optExposePort :: !Word16, - optRestundUDPStatusPort :: !Word16, - optRestundUDPListenPort :: !Word16, - optTier :: !Text, - optZone :: !ByteString - } - deriving (Show) - -parseOpts :: ParserInfo Opts -parseOpts = info (helper <*> parser) desc - where - desc = header "restund Metrics Exporter" <> fullDesc - - parser = - Opts - <$> option - auto - ( short 'p' - <> long "port" - <> metavar "PORT" - <> help "Expose metrics on this port" - <> value 9200 - <> showDefault - ) - <*> option - auto - ( long "restund-udp-status-port" - <> metavar "PORT" - <> help "UDP Status Port" - <> value 33000 - <> showDefault - ) - <*> option - auto - ( long "restund-udp-listen-port" - <> metavar "PORT" - <> help "UDP Listen Port (aka STUN port aka Management port)" - <> value 3478 - <> showDefault - ) - <*> option - txt - ( long "tier" - <> help "Deployment Tier" - ) - <*> option - bs - ( long "zone" - <> value "wire.com" - <> help "Deployment Zone" - <> showDefault - ) - - txt = Text.pack <$> str - bs = ByteString.pack <$> str - -main :: IO () -main = withSocketsDo $ do - opts <- execParser parseOpts - lgr <- Log.new Log.defSettings - rlv <- makeResolvSeed defaultResolvConf - - let labels = - fromList - [ ("tier", optTier opts), - ("app", "restund"), - ("srv", "rex") - ] - dns = - mconcat - [ "_turn._tcp.", - encodeUtf8 (optTier opts), - ".", - optZone opts, - "." - ] - - runRegistryT $ do - known <- knownStats labels - unknown <- registerCounter "UNKNOWN" labels - rxq <- registerGauge "recv_queue" labels - txq <- registerGauge "send_queue" labels - drp <- registerGauge "packet_drops" labels - peers <- registerGauge "known_peers" labels - rpeers <- registerGauge "reachable_peers" labels - - timing <- - registerHistogram - "scrape_timing_ns" - labels - [ 500000, -- .5 ms - 1000000, -- 1 ms - 5000000 -- 5 ms - ] - - sampleIO <- sample - - liftIO . serveIO opts $ do - Log.info lgr $ msg (val "Scraping ...") - start <- getTime Monotonic - - (!_, !_, !_) <- - runConcurrently $ - (,,) - <$> Concurrently - ( do - sockStats <- getSocketStats (optRestundUDPListenPort opts) - Log.trace lgr $ msg (show sockStats) - for_ sockStats $ \SocketStats {..} -> do - Gauge.set (fromIntegral rxQueue) rxq - Gauge.set (fromIntegral txQueue) txq - Gauge.set (fromIntegral drops) drp - ) - <*> Concurrently - ( withSocket $ \ssock -> do - appStats <- getAppStats lgr (statusAddr opts) ssock - Log.trace lgr $ msg (show appStats) - for_ appStats $ \(k, v) -> - maybe - (Counter.inc unknown) - (Gauge.set v) - (HashMap.lookup k known) - ) - <*> Concurrently - ( do - peerStats <- getPeerConnectivityStats lgr rlv dns - Log.trace lgr $ msg (show peerStats) - Gauge.set (fromIntegral (peersDiscovered peerStats)) peers - Gauge.set (fromIntegral (peersReachable peerStats)) rpeers - ) - - !took <- toNanoSecs . (`diffTimeSpec` start) <$> getTime Monotonic - Log.info lgr $ msg ("Done scaping in " <> show took <> "ns") - Histo.observe (fromIntegral took) timing - - sampleIO - where - localhost = tupleToHostAddress (127, 0, 0, 1) - - statusAddr Opts {optRestundUDPStatusPort = p} = - SockAddrInet (fromIntegral p) localhost - - withSocket = - bracket - (socket AF_INET Datagram defaultProtocol) - close - -data SocketStats = SocketStats - { lPort :: !Word16, - rxQueue :: Word64, - txQueue :: Word64, - drops :: Word64 - } - deriving (Show) - --- nb. that this requires restund and rex to run in the same network namespace --- (ie. either both run with --net=host, or both run in the same pod) -getSocketStats :: Word16 -> IO (Maybe SocketStats) -getSocketStats port = do - pnu <- Text.readFile "/proc/net/udp" - pure - . find ((== port) . lPort) - . map (mk . Text.words) - . drop 1 - $ Text.lines pnu - where - -- sl local_address rem_address st tx_queue:rx_queue tr:tm->when retrnsmt uid timeout inode ref pointer drops - mk [_, la, _, _, qs, _, _, _, _, _, _, _, ds] = - let p = hex . snd . Text.breakOnEnd ":" $ la - (rx, tx) = bimap hex hex . Text.breakOn ":" $ qs - d = either (const 0) fst . Text.decimal $ ds - in SocketStats p rx tx d - - hex :: (Integral a, Bounded a) => Text -> a - hex = either (const minBound) fst . Text.hexadecimal - -getAppStats :: Log.Logger -> SockAddr -> Socket -> IO [(Text, Double)] -getAppStats lgr addr sock = fmap mconcat . for cmds $ \cmd -> do - sendAllTo sock cmd addr - (reply, _) <- recvFrom sock 1024 - Log.trace lgr $ msg (ByteString.intercalate "\n" (ByteString.lines reply)) - pure $ - parseAppStats reply - where - cmds = ["stat", "turnstats", "turnreply", "tcpstats", "authstats"] - -parseAppStats :: ByteString -> [(Text, Double)] -parseAppStats = - mapMaybe - ( bitraverse Just id - . bimap - decodeUtf8 - ( either (const Nothing) Just - . Parser.parseOnly - (Parser.skipWhile Parser.isSpace *> Parser.double) - ) - . ByteString.break (== ' ') - ) - . ByteString.lines - -knownStats :: Labels -> RegistryT IO (HashMap Text Gauge) -knownStats def = - HashMap.fromList - <$> traverse - (mk def) - [ -- stat - "binding_req", - "allocate_req", - "refresh_req", - "createperm_req", - "chanbind_req", - "unknown_req", - -- turnstats - "allocs_cur", - "allocs_tot", - "bytes_tx", - "bytes_rx", - "bytes_tot", - -- turnreply - "scode_400", - "scode_420", - "scode_437", - "scode_440", - "scode_441", - "scode_442", - "scode_443", - "scode_500", - "scode_508", - -- tcpstats - "tcp_connections", - "tls_connections", - -- authstats - "auth_req_mi", - "auth_req_no_mi" - ] - where - mk :: Labels -> Name -> RegistryT IO (Text, Gauge) - mk labels name = do - g <- registerGauge name labels - pure (unName name, g) - -data PeerConnectivityStats = PeerConnectivityStats - { peersDiscovered :: Int, - peersReachable :: Int - } - deriving (Show) - -getPeerConnectivityStats :: - Log.Logger -> - ResolvSeed -> - Domain -> - IO PeerConnectivityStats -getPeerConnectivityStats lgr seed dom = do - addrs <- disco - reach <- length . catMaybes <$> mapConcurrently shakehands addrs - pure - PeerConnectivityStats - { peersDiscovered = length addrs, - peersReachable = reach - } - where - disco = withResolver seed $ \rlv -> - lookupSRV rlv dom - >>= either - (const $ pure []) - ( \xs -> - concatMap mkAddr . zip xs - <$> traverse (lookupA rlv . _4) xs - ) - - shakehands (addr, port) = - handleIOError (\e -> logUnreachable addr port e $> Nothing) - . timeout (5 * 1000000) - $ bracket - (socket AF_INET Stream defaultProtocol) - close - (`connect` SockAddrInet (fromIntegral port) (toHostAddress addr)) - - mkAddr (_, Left _) = mempty - mkAddr (rr, Right ips) = (,_3 rr) <$> ips - - _4 (_, _, _, x) = x - _3 (_, _, x, _) = x - - logUnreachable addr port e = - Log.warn lgr . msg $ - "Peer " <> show addr <> ":" <> show port <> " unreachable: " <> show e - -serveIO :: (MonadIO m) => Opts -> IO RegistrySample -> m () -serveIO opts runSample = - liftIO $ - runSettings - ( setPort (fromIntegral (optExposePort opts)) - . setHost "127.0.0.1" - $ defaultSettings - ) - (app runSample) - -app :: IO RegistrySample -> Application -app runSample req respond = case pathInfo req of - ("metrics" : _) -> runSample >>= respond . r200 - _ -> respond r404 - where - r200 = responseBuilder status200 hdrs . encodeMetrics - r404 = responseLBS status404 hdrs mempty - hdrs = [(hContentType, "text/plain")] diff --git a/tools/rex/README.md b/tools/rex/README.md deleted file mode 100644 index 99a36f71115..00000000000 --- a/tools/rex/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# Rex - -Restund-exporer: A service scraping metrics from `restund` and exposing them in a format understood by the `prometheus` monitoring system. - -For instance it can show the number of current allocations (ongoing calls): - -``` -curl -s localhost:9200/metrics | grep allocs_cur -# TYPE allocs_cur gauge -allocs_cur{app="restund",srv="rex",tier="staging"} 15.0 -``` diff --git a/tools/rex/default.nix b/tools/rex/default.nix deleted file mode 100644 index 02d05d765d4..00000000000 --- a/tools/rex/default.nix +++ /dev/null @@ -1,56 +0,0 @@ -# WARNING: GENERATED FILE, DO NOT EDIT. -# This file is generated by running hack/bin/generate-local-nix-packages.sh and -# must be regenerated whenever local packages are added or removed, or -# dependencies are added or removed. -{ mkDerivation -, async -, attoparsec -, base -, bytestring -, clock -, dns -, exceptions -, gitignoreSource -, http-types -, iproute -, lib -, mtl -, network -, optparse-applicative -, prometheus -, text -, tinylog -, unordered-containers -, wai -, warp -}: -mkDerivation { - pname = "rex"; - version = "0.3.0"; - src = gitignoreSource ./.; - isLibrary = false; - isExecutable = true; - executableHaskellDepends = [ - async - attoparsec - base - bytestring - clock - dns - exceptions - http-types - iproute - mtl - network - optparse-applicative - prometheus - text - tinylog - unordered-containers - wai - warp - ]; - description = "Scrape and expose restund metrics for prometheus"; - license = lib.licenses.agpl3Only; - mainProgram = "rex"; -} diff --git a/tools/rex/rex.cabal b/tools/rex/rex.cabal deleted file mode 100644 index d317815b3f6..00000000000 --- a/tools/rex/rex.cabal +++ /dev/null @@ -1,46 +0,0 @@ -cabal-version: >=1.10 -name: rex -version: 0.3.0 -synopsis: Scrape and expose restund metrics for prometheus -description: @rex@ = @restund-exporter@ in prometheus jargon -category: Network -author: Wire Swiss GmbH -maintainer: Wire Swiss GmbH -license: AGPL-3 -license-file: LICENSE -build-type: Simple - -flag static - description: Enable static linking - default: False - -executable rex - main-is: Main.hs - build-depends: - async - , attoparsec - , base >=4 && <5 - , bytestring - , clock - , dns >=2.0.8 - , exceptions - , http-types - , iproute - , mtl - , network - , optparse-applicative - , prometheus - , text - , tinylog - , unordered-containers - , wai - , warp - - ghc-options: - -Wall -O1 -funbox-small-strict-fields -Wredundant-constraints - -Wunused-packages - - if flag(static) - ld-options: -static - - default-language: Haskell2010 diff --git a/treefmt.toml b/treefmt.toml index 1cd7408a8ff..949295a0b4c 100644 --- a/treefmt.toml +++ b/treefmt.toml @@ -17,5 +17,4 @@ includes = ["*.sh"] excludes = [ "dist-newstyle/", "services/nginz/third_party/*", - "services/restund/*", ]