Repository files navigation

feed-example-redis

This is a fully working sample program designed to ingest Spur feeds into a Redis database.

The Go binary provides 3 commands:

  1. daemon - Runs indefinitely, checks for the latest feed, and inserts it into Redis, updates using real-time data if your token supports it.
  2. insert - Inserts a feed file into Redis and exits.
  3. merge - Merges a real-time file into Redis and exits.

Requirements

To run this program, you will need:

  • Go installed on your machine.
  • Docker for managing containers.
  • A Spur token with access to feeds and optionally real-time data. This should be exposed in your environment as `SPUR_REDIS_API_TOKEN`.

System Requirements

  • Anonymous feeds require 5GB of memory.
  • Anonymous residential feeds require a minimum 18GB of memory.

Quickstart

To just run the app with a redis server, you can use the following Docker Compose file. This will start a Redis server and the feed-example-redis app. Please see the Configuration section for more information on the environment variables. NOTE: You will need to set the SPUR_REDIS_API_TOKEN environment variable to your Spur token.

version: '3'
services:
redis:
image: redis
ports:
- "6379:6379"
healthcheck:
test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ]
interval: 30s
timeout: 10s
retries: 5
spurredis:
image: spurintelligence/spurredis:latest
depends_on:
redis:
condition: service_healthy
ports:
- "8080:8080"
environment:
SPUR_REDIS_API_TOKEN: ${SPUR_REDIS_API_TOKEN}
SPUR_REDIS_FEED_TYPE: anonymous
SPUR_REDIS_CHUNK_SIZE: 5000
SPUR_REDIS_ADDR: redis:6379
SPUR_REDIS_LOCAL_API_AUTH_TOKENS: testtoken1,testtoken2

Then run the following command to test the API:

curl -vv -H "TOKEN: testtoken1" localhost:8080/v2/context/${YOUR_IP}| jq

Running

You have three options for running the application: local development with Docker, production with Docker Compose, or building the binary directly.

Option 1 - Local Development with Docker Compose

This builds a local Docker image with your changes and runs it with Docker Compose:

# Clone the repository
git clone https://github.com/spurintel/feed-example-redis.git
# Set the environment variables, minimum required is the Spur tokenexport SPUR_REDIS_API_TOKEN=your_spur_token
# Build and run with local changescd feed-example-redis
make run

Important: Make sure to export your environment variables (especially SPUR_REDIS_API_TOKEN) before running the make commands, as the Makefile passes these through to Docker Compose.

The local development setup automatically detects your platform (ARM64/AMD64) and builds the appropriate Docker image for your architecture.

Option 2 - Production with Docker Compose

This uses the published Docker image from Docker Hub:

# Set the environment variables, minimum required is the Spur tokenexport SPUR_REDIS_API_TOKEN=your_spur_token
# Run with production image
make run-prod

Option 3 - Build and run the binary directly

# Build the binarycd feed-example-redis
make
# Start a Redis server
docker run --rm -p 6379:6379 --name redis redis:latest
# Run the binary in daemon mode, assumes you have your token and other configurations set in a .env fileexport$(cat .env | xargs)&& ./target/spurredis_darwin_arm64 daemon

Available Make Targets

Run make help to see all available targets with descriptions, or use these common ones:

  • make run - Local development (builds local Docker image and runs with Docker Compose)
  • make run-local - Same as make run
  • make run-prod - Production (uses published Docker image)
  • make build-local - Build local Docker image only
  • make clean - Remove build artifacts and local Docker image
  • make bin - Build native binary for your platform
  • make bin-linux - Build Linux binary
  • make test - Run tests
  • make format - Format code
  • make lint - Run linter

Configuring and Running the API Locally

To run the API server locally, use the `-api` flag when starting the binary in daemon mode. This will start the local API server along with the daemon process:

# Run the binary with the API server enabledexport\$(cat .env | xargs) && ./target/spurredis_darwin_arm64 -api daemon

Ensure the environment variables are set correctly, especially `SPUR_REDIS_LOCAL_API_AUTH_TOKENS`, to use the API authentication.

API Usage Examples

Below are examples of how to interact with the API using curl:

Get context for an IP address

Replace your_auth_token with one of your valid API tokens and your_ip_address with the IP address you want to query.

curl -H "TOKEN: your_auth_token" http://localhost:PORT/v2/context/your_ip_address

Make sure to replace `PORT` with the actual port number your API server is listening on.

Configuration

The application can be configured through the following environment variables:

  • SPUR_REDIS_CHUNK_SIZE: Sets the chunk size for Redis operations. (default: 5000)
  • SPUR_REDIS_TTL: Sets the TTL (in hours) for Redis keys. (default: 24)
  • SPUR_REDIS_ADDR: Sets the Redis server address. (default: "localhost:6379")
  • SPUR_REDIS_PASS: Sets the Redis password. (default: "")
  • SPUR_REDIS_DB: Sets the Redis DB. (default: 0)
  • SPUR_REDIS_CONCURRENT_NUM: Sets the number of concurrent processes. (default: number of CPUs)
  • SPUR_REDIS_API_TOKEN: Sets the Spur API token. (Required)
  • SPUR_REDIS_FEED_TYPE: Sets the Spur feed type. (default: "anonymous")
  • SPUR_REDIS_REALTIME_ENABLED: Sets whether realtime feed is enabled. (default: false)
  • SPUR_REDIS_PORT: Sets the port for the application. (default: 8080)
  • SPUR_REDIS_CERT_FILE: Specifies the TLS Cert file. (default: "")
  • SPUR_REDIS_KEY_FILE: Specifies the TLS Key file. (default: "")
  • SPUR_REDIS_LOCAL_API_AUTH_TOKENS: Sets the local API Auth tokens. (Required; Tokens are comma separated)
  • SPUR_REDIS_IPV6_NETWORK_FEED_BETA: Also include data from IPv6 network info feeds (BETA). May increase resource requirements.

Please note: For SPUR_REDIS_API_TOKEN and SPUR_REDIS_LOCAL_API_AUTH_TOKENS, if these are not set, the application will not run.

Querying for the Data

docker exec -it redis redis-cli GET 1.2.3.4

Ensure all sensitive information and configurations are securely stored and not exposed unnecessarily.

About

Sample program to ingest Spur feeds into a redis database

Resources

Stars

1 star

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Repository files navigation

feed-example-redis

This is a fully working sample program designed to ingest Spur feeds into a Redis database.

The Go binary provides 3 commands:

  1. daemon - Runs indefinitely, checks for the latest feed, and inserts it into Redis, updates using real-time data if your token supports it.
  2. insert - Inserts a feed file into Redis and exits.
  3. merge - Merges a real-time file into Redis and exits.

Requirements

To run this program, you will need:

  • Go installed on your machine.
  • Docker for managing containers.
  • A Spur token with access to feeds and optionally real-time data. This should be exposed in your environment as `SPUR_REDIS_API_TOKEN`.

System Requirements

  • Anonymous feeds require 5GB of memory.
  • Anonymous residential feeds require a minimum 18GB of memory.

Quickstart

To just run the app with a redis server, you can use the following Docker Compose file. This will start a Redis server and the feed-example-redis app. Please see the Configuration section for more information on the environment variables. NOTE: You will need to set the SPUR_REDIS_API_TOKEN environment variable to your Spur token.

version: '3'
services:
redis:
image: redis
ports:
- "6379:6379"
healthcheck:
test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ]
interval: 30s
timeout: 10s
retries: 5
spurredis:
image: spurintelligence/spurredis:latest
depends_on:
redis:
condition: service_healthy
ports:
- "8080:8080"
environment:
SPUR_REDIS_API_TOKEN: ${SPUR_REDIS_API_TOKEN}
SPUR_REDIS_FEED_TYPE: anonymous
SPUR_REDIS_CHUNK_SIZE: 5000
SPUR_REDIS_ADDR: redis:6379
SPUR_REDIS_LOCAL_API_AUTH_TOKENS: testtoken1,testtoken2

Then run the following command to test the API:

curl -vv -H "TOKEN: testtoken1" localhost:8080/v2/context/${YOUR_IP}| jq

Running

You have three options for running the application: local development with Docker, production with Docker Compose, or building the binary directly.

Option 1 - Local Development with Docker Compose

This builds a local Docker image with your changes and runs it with Docker Compose:

# Clone the repository
git clone https://github.com/spurintel/feed-example-redis.git
# Set the environment variables, minimum required is the Spur tokenexport SPUR_REDIS_API_TOKEN=your_spur_token
# Build and run with local changescd feed-example-redis
make run

Important: Make sure to export your environment variables (especially SPUR_REDIS_API_TOKEN) before running the make commands, as the Makefile passes these through to Docker Compose.

The local development setup automatically detects your platform (ARM64/AMD64) and builds the appropriate Docker image for your architecture.

Option 2 - Production with Docker Compose

This uses the published Docker image from Docker Hub:

# Set the environment variables, minimum required is the Spur tokenexport SPUR_REDIS_API_TOKEN=your_spur_token
# Run with production image
make run-prod

Option 3 - Build and run the binary directly

# Build the binarycd feed-example-redis
make
# Start a Redis server
docker run --rm -p 6379:6379 --name redis redis:latest
# Run the binary in daemon mode, assumes you have your token and other configurations set in a .env fileexport$(cat .env | xargs)&& ./target/spurredis_darwin_arm64 daemon

Available Make Targets

Run make help to see all available targets with descriptions, or use these common ones:

  • make run - Local development (builds local Docker image and runs with Docker Compose)
  • make run-local - Same as make run
  • make run-prod - Production (uses published Docker image)
  • make build-local - Build local Docker image only
  • make clean - Remove build artifacts and local Docker image
  • make bin - Build native binary for your platform
  • make bin-linux - Build Linux binary
  • make test - Run tests
  • make format - Format code
  • make lint - Run linter

Configuring and Running the API Locally

To run the API server locally, use the `-api` flag when starting the binary in daemon mode. This will start the local API server along with the daemon process:

# Run the binary with the API server enabledexport\$(cat .env | xargs) && ./target/spurredis_darwin_arm64 -api daemon

Ensure the environment variables are set correctly, especially `SPUR_REDIS_LOCAL_API_AUTH_TOKENS`, to use the API authentication.

API Usage Examples

Below are examples of how to interact with the API using curl:

Get context for an IP address

Replace your_auth_token with one of your valid API tokens and your_ip_address with the IP address you want to query.

curl -H "TOKEN: your_auth_token" http://localhost:PORT/v2/context/your_ip_address

Make sure to replace `PORT` with the actual port number your API server is listening on.

Configuration

The application can be configured through the following environment variables:

  • SPUR_REDIS_CHUNK_SIZE: Sets the chunk size for Redis operations. (default: 5000)
  • SPUR_REDIS_TTL: Sets the TTL (in hours) for Redis keys. (default: 24)
  • SPUR_REDIS_ADDR: Sets the Redis server address. (default: "localhost:6379")
  • SPUR_REDIS_PASS: Sets the Redis password. (default: "")
  • SPUR_REDIS_DB: Sets the Redis DB. (default: 0)
  • SPUR_REDIS_CONCURRENT_NUM: Sets the number of concurrent processes. (default: number of CPUs)
  • SPUR_REDIS_API_TOKEN: Sets the Spur API token. (Required)
  • SPUR_REDIS_FEED_TYPE: Sets the Spur feed type. (default: "anonymous")
  • SPUR_REDIS_REALTIME_ENABLED: Sets whether realtime feed is enabled. (default: false)
  • SPUR_REDIS_PORT: Sets the port for the application. (default: 8080)
  • SPUR_REDIS_CERT_FILE: Specifies the TLS Cert file. (default: "")
  • SPUR_REDIS_KEY_FILE: Specifies the TLS Key file. (default: "")
  • SPUR_REDIS_LOCAL_API_AUTH_TOKENS: Sets the local API Auth tokens. (Required; Tokens are comma separated)
  • SPUR_REDIS_IPV6_NETWORK_FEED_BETA: Also include data from IPv6 network info feeds (BETA). May increase resource requirements.

Please note: For SPUR_REDIS_API_TOKEN and SPUR_REDIS_LOCAL_API_AUTH_TOKENS, if these are not set, the application will not run.

Querying for the Data

docker exec -it redis redis-cli GET 1.2.3.4

Ensure all sensitive information and configurations are securely stored and not exposed unnecessarily.

About

Sample program to ingest Spur feeds into a redis database

Resources

Stars

1 star

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

feed-example-redis

This is a fully working sample program designed to ingest Spur feeds into a Redis database.

The Go binary provides 3 commands:

  1. daemon - Runs indefinitely, checks for the latest feed, and inserts it into Redis, updates using real-time data if your token supports it.
  2. insert - Inserts a feed file into Redis and exits.
  3. merge - Merges a real-time file into Redis and exits.

Requirements

To run this program, you will need:

  • Go installed on your machine.
  • Docker for managing containers.
  • A Spur token with access to feeds and optionally real-time data. This should be exposed in your environment as `SPUR_REDIS_API_TOKEN`.

System Requirements

  • Anonymous feeds require 5GB of memory.
  • Anonymous residential feeds require a minimum 18GB of memory.

Quickstart

To just run the app with a redis server, you can use the following Docker Compose file. This will start a Redis server and the feed-example-redis app. Please see the Configuration section for more information on the environment variables. NOTE: You will need to set the SPUR_REDIS_API_TOKEN environment variable to your Spur token.

version: '3'
services:
redis:
image: redis
ports:
- "6379:6379"
healthcheck:
test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ]
interval: 30s
timeout: 10s
retries: 5
spurredis:
image: spurintelligence/spurredis:latest
depends_on:
redis:
condition: service_healthy
ports:
- "8080:8080"
environment:
SPUR_REDIS_API_TOKEN: ${SPUR_REDIS_API_TOKEN}
SPUR_REDIS_FEED_TYPE: anonymous
SPUR_REDIS_CHUNK_SIZE: 5000
SPUR_REDIS_ADDR: redis:6379
SPUR_REDIS_LOCAL_API_AUTH_TOKENS: testtoken1,testtoken2

Then run the following command to test the API:

curl -vv -H "TOKEN: testtoken1" localhost:8080/v2/context/${YOUR_IP}| jq

Running

You have three options for running the application: local development with Docker, production with Docker Compose, or building the binary directly.

Option 1 - Local Development with Docker Compose

This builds a local Docker image with your changes and runs it with Docker Compose:

# Clone the repository
git clone https://github.com/spurintel/feed-example-redis.git
# Set the environment variables, minimum required is the Spur tokenexport SPUR_REDIS_API_TOKEN=your_spur_token
# Build and run with local changescd feed-example-redis
make run

Important: Make sure to export your environment variables (especially SPUR_REDIS_API_TOKEN) before running the make commands, as the Makefile passes these through to Docker Compose.

The local development setup automatically detects your platform (ARM64/AMD64) and builds the appropriate Docker image for your architecture.

Option 2 - Production with Docker Compose

This uses the published Docker image from Docker Hub:

# Set the environment variables, minimum required is the Spur tokenexport SPUR_REDIS_API_TOKEN=your_spur_token
# Run with production image
make run-prod

Option 3 - Build and run the binary directly

# Build the binarycd feed-example-redis
make
# Start a Redis server
docker run --rm -p 6379:6379 --name redis redis:latest
# Run the binary in daemon mode, assumes you have your token and other configurations set in a .env fileexport$(cat .env | xargs)&& ./target/spurredis_darwin_arm64 daemon

Available Make Targets

Run make help to see all available targets with descriptions, or use these common ones:

  • make run - Local development (builds local Docker image and runs with Docker Compose)
  • make run-local - Same as make run
  • make run-prod - Production (uses published Docker image)
  • make build-local - Build local Docker image only
  • make clean - Remove build artifacts and local Docker image
  • make bin - Build native binary for your platform
  • make bin-linux - Build Linux binary
  • make test - Run tests
  • make format - Format code
  • make lint - Run linter

Configuring and Running the API Locally

To run the API server locally, use the `-api` flag when starting the binary in daemon mode. This will start the local API server along with the daemon process:

# Run the binary with the API server enabledexport\$(cat .env | xargs) && ./target/spurredis_darwin_arm64 -api daemon

Ensure the environment variables are set correctly, especially `SPUR_REDIS_LOCAL_API_AUTH_TOKENS`, to use the API authentication.

API Usage Examples

Below are examples of how to interact with the API using curl:

Get context for an IP address

Replace your_auth_token with one of your valid API tokens and your_ip_address with the IP address you want to query.

curl -H "TOKEN: your_auth_token" http://localhost:PORT/v2/context/your_ip_address

Make sure to replace `PORT` with the actual port number your API server is listening on.

Configuration

The application can be configured through the following environment variables:

  • SPUR_REDIS_CHUNK_SIZE: Sets the chunk size for Redis operations. (default: 5000)
  • SPUR_REDIS_TTL: Sets the TTL (in hours) for Redis keys. (default: 24)
  • SPUR_REDIS_ADDR: Sets the Redis server address. (default: "localhost:6379")
  • SPUR_REDIS_PASS: Sets the Redis password. (default: "")
  • SPUR_REDIS_DB: Sets the Redis DB. (default: 0)
  • SPUR_REDIS_CONCURRENT_NUM: Sets the number of concurrent processes. (default: number of CPUs)
  • SPUR_REDIS_API_TOKEN: Sets the Spur API token. (Required)
  • SPUR_REDIS_FEED_TYPE: Sets the Spur feed type. (default: "anonymous")
  • SPUR_REDIS_REALTIME_ENABLED: Sets whether realtime feed is enabled. (default: false)
  • SPUR_REDIS_PORT: Sets the port for the application. (default: 8080)
  • SPUR_REDIS_CERT_FILE: Specifies the TLS Cert file. (default: "")
  • SPUR_REDIS_KEY_FILE: Specifies the TLS Key file. (default: "")
  • SPUR_REDIS_LOCAL_API_AUTH_TOKENS: Sets the local API Auth tokens. (Required; Tokens are comma separated)
  • SPUR_REDIS_IPV6_NETWORK_FEED_BETA: Also include data from IPv6 network info feeds (BETA). May increase resource requirements.

Please note: For SPUR_REDIS_API_TOKEN and SPUR_REDIS_LOCAL_API_AUTH_TOKENS, if these are not set, the application will not run.

Querying for the Data

docker exec -it redis redis-cli GET 1.2.3.4

Ensure all sensitive information and configurations are securely stored and not exposed unnecessarily.

About

Sample program to ingest Spur feeds into a redis database

Resources

Stars

1 star

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

feed-example-redis

This is a fully working sample program designed to ingest Spur feeds into a Redis database.

The Go binary provides 3 commands:

  1. daemon - Runs indefinitely, checks for the latest feed, and inserts it into Redis, updates using real-time data if your token supports it.
  2. insert - Inserts a feed file into Redis and exits.
  3. merge - Merges a real-time file into Redis and exits.

Requirements

To run this program, you will need:

  • Go installed on your machine.
  • Docker for managing containers.
  • A Spur token with access to feeds and optionally real-time data. This should be exposed in your environment as `SPUR_REDIS_API_TOKEN`.

System Requirements

  • Anonymous feeds require 5GB of memory.
  • Anonymous residential feeds require a minimum 18GB of memory.

Quickstart

To just run the app with a redis server, you can use the following Docker Compose file. This will start a Redis server and the feed-example-redis app. Please see the Configuration section for more information on the environment variables. NOTE: You will need to set the SPUR_REDIS_API_TOKEN environment variable to your Spur token.

version: '3'
services:
redis:
image: redis
ports:
- "6379:6379"
healthcheck:
test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ]
interval: 30s
timeout: 10s
retries: 5
spurredis:
image: spurintelligence/spurredis:latest
depends_on:
redis:
condition: service_healthy
ports:
- "8080:8080"
environment:
SPUR_REDIS_API_TOKEN: ${SPUR_REDIS_API_TOKEN}
SPUR_REDIS_FEED_TYPE: anonymous
SPUR_REDIS_CHUNK_SIZE: 5000
SPUR_REDIS_ADDR: redis:6379
SPUR_REDIS_LOCAL_API_AUTH_TOKENS: testtoken1,testtoken2

Then run the following command to test the API:

curl -vv -H "TOKEN: testtoken1" localhost:8080/v2/context/${YOUR_IP}| jq

Running

You have three options for running the application: local development with Docker, production with Docker Compose, or building the binary directly.

Option 1 - Local Development with Docker Compose

This builds a local Docker image with your changes and runs it with Docker Compose:

# Clone the repository
git clone https://github.com/spurintel/feed-example-redis.git
# Set the environment variables, minimum required is the Spur tokenexport SPUR_REDIS_API_TOKEN=your_spur_token
# Build and run with local changescd feed-example-redis
make run

Important: Make sure to export your environment variables (especially SPUR_REDIS_API_TOKEN) before running the make commands, as the Makefile passes these through to Docker Compose.

The local development setup automatically detects your platform (ARM64/AMD64) and builds the appropriate Docker image for your architecture.

Option 2 - Production with Docker Compose

This uses the published Docker image from Docker Hub:

# Set the environment variables, minimum required is the Spur tokenexport SPUR_REDIS_API_TOKEN=your_spur_token
# Run with production image
make run-prod

Option 3 - Build and run the binary directly

# Build the binarycd feed-example-redis
make
# Start a Redis server
docker run --rm -p 6379:6379 --name redis redis:latest
# Run the binary in daemon mode, assumes you have your token and other configurations set in a .env fileexport$(cat .env | xargs)&& ./target/spurredis_darwin_arm64 daemon

Available Make Targets

Run make help to see all available targets with descriptions, or use these common ones:

  • make run - Local development (builds local Docker image and runs with Docker Compose)
  • make run-local - Same as make run
  • make run-prod - Production (uses published Docker image)
  • make build-local - Build local Docker image only
  • make clean - Remove build artifacts and local Docker image
  • make bin - Build native binary for your platform
  • make bin-linux - Build Linux binary
  • make test - Run tests
  • make format - Format code
  • make lint - Run linter

Configuring and Running the API Locally

To run the API server locally, use the `-api` flag when starting the binary in daemon mode. This will start the local API server along with the daemon process:

# Run the binary with the API server enabledexport\$(cat .env | xargs) && ./target/spurredis_darwin_arm64 -api daemon

Ensure the environment variables are set correctly, especially `SPUR_REDIS_LOCAL_API_AUTH_TOKENS`, to use the API authentication.

API Usage Examples

Below are examples of how to interact with the API using curl:

Get context for an IP address

Replace your_auth_token with one of your valid API tokens and your_ip_address with the IP address you want to query.

curl -H "TOKEN: your_auth_token" http://localhost:PORT/v2/context/your_ip_address

Make sure to replace `PORT` with the actual port number your API server is listening on.

Configuration

The application can be configured through the following environment variables:

  • SPUR_REDIS_CHUNK_SIZE: Sets the chunk size for Redis operations. (default: 5000)
  • SPUR_REDIS_TTL: Sets the TTL (in hours) for Redis keys. (default: 24)
  • SPUR_REDIS_ADDR: Sets the Redis server address. (default: "localhost:6379")
  • SPUR_REDIS_PASS: Sets the Redis password. (default: "")
  • SPUR_REDIS_DB: Sets the Redis DB. (default: 0)
  • SPUR_REDIS_CONCURRENT_NUM: Sets the number of concurrent processes. (default: number of CPUs)
  • SPUR_REDIS_API_TOKEN: Sets the Spur API token. (Required)
  • SPUR_REDIS_FEED_TYPE: Sets the Spur feed type. (default: "anonymous")
  • SPUR_REDIS_REALTIME_ENABLED: Sets whether realtime feed is enabled. (default: false)
  • SPUR_REDIS_PORT: Sets the port for the application. (default: 8080)
  • SPUR_REDIS_CERT_FILE: Specifies the TLS Cert file. (default: "")
  • SPUR_REDIS_KEY_FILE: Specifies the TLS Key file. (default: "")
  • SPUR_REDIS_LOCAL_API_AUTH_TOKENS: Sets the local API Auth tokens. (Required; Tokens are comma separated)
  • SPUR_REDIS_IPV6_NETWORK_FEED_BETA: Also include data from IPv6 network info feeds (BETA). May increase resource requirements.

Please note: For SPUR_REDIS_API_TOKEN and SPUR_REDIS_LOCAL_API_AUTH_TOKENS, if these are not set, the application will not run.

Querying for the Data

docker exec -it redis redis-cli GET 1.2.3.4

Ensure all sensitive information and configurations are securely stored and not exposed unnecessarily.

About

Sample program to ingest Spur feeds into a redis database

Resources

Stars

1 star

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Repository files navigation

feed-example-redis

This is a fully working sample program designed to ingest Spur feeds into a Redis database.

The Go binary provides 3 commands:

  1. daemon - Runs indefinitely, checks for the latest feed, and inserts it into Redis, updates using real-time data if your token supports it.
  2. insert - Inserts a feed file into Redis and exits.
  3. merge - Merges a real-time file into Redis and exits.

Requirements

To run this program, you will need:

  • Go installed on your machine.
  • Docker for managing containers.
  • A Spur token with access to feeds and optionally real-time data. This should be exposed in your environment as `SPUR_REDIS_API_TOKEN`.

System Requirements

  • Anonymous feeds require 5GB of memory.
  • Anonymous residential feeds require a minimum 18GB of memory.

Quickstart

To just run the app with a redis server, you can use the following Docker Compose file. This will start a Redis server and the feed-example-redis app. Please see the Configuration section for more information on the environment variables. NOTE: You will need to set the SPUR_REDIS_API_TOKEN environment variable to your Spur token.

version: '3'
services:
redis:
image: redis
ports:
- "6379:6379"
healthcheck:
test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ]
interval: 30s
timeout: 10s
retries: 5
spurredis:
image: spurintelligence/spurredis:latest
depends_on:
redis:
condition: service_healthy
ports:
- "8080:8080"
environment:
SPUR_REDIS_API_TOKEN: ${SPUR_REDIS_API_TOKEN}
SPUR_REDIS_FEED_TYPE: anonymous
SPUR_REDIS_CHUNK_SIZE: 5000
SPUR_REDIS_ADDR: redis:6379
SPUR_REDIS_LOCAL_API_AUTH_TOKENS: testtoken1,testtoken2

Then run the following command to test the API:

curl -vv -H "TOKEN: testtoken1" localhost:8080/v2/context/${YOUR_IP}| jq

Running

You have three options for running the application: local development with Docker, production with Docker Compose, or building the binary directly.

Option 1 - Local Development with Docker Compose

This builds a local Docker image with your changes and runs it with Docker Compose:

# Clone the repository
git clone https://github.com/spurintel/feed-example-redis.git
# Set the environment variables, minimum required is the Spur tokenexport SPUR_REDIS_API_TOKEN=your_spur_token
# Build and run with local changescd feed-example-redis
make run

Important: Make sure to export your environment variables (especially SPUR_REDIS_API_TOKEN) before running the make commands, as the Makefile passes these through to Docker Compose.

The local development setup automatically detects your platform (ARM64/AMD64) and builds the appropriate Docker image for your architecture.

Option 2 - Production with Docker Compose

This uses the published Docker image from Docker Hub:

# Set the environment variables, minimum required is the Spur tokenexport SPUR_REDIS_API_TOKEN=your_spur_token
# Run with production image
make run-prod

Option 3 - Build and run the binary directly

# Build the binarycd feed-example-redis
make
# Start a Redis server
docker run --rm -p 6379:6379 --name redis redis:latest
# Run the binary in daemon mode, assumes you have your token and other configurations set in a .env fileexport$(cat .env | xargs)&& ./target/spurredis_darwin_arm64 daemon

Available Make Targets

Run make help to see all available targets with descriptions, or use these common ones:

  • make run - Local development (builds local Docker image and runs with Docker Compose)
  • make run-local - Same as make run
  • make run-prod - Production (uses published Docker image)
  • make build-local - Build local Docker image only
  • make clean - Remove build artifacts and local Docker image
  • make bin - Build native binary for your platform
  • make bin-linux - Build Linux binary
  • make test - Run tests
  • make format - Format code
  • make lint - Run linter

Configuring and Running the API Locally

To run the API server locally, use the `-api` flag when starting the binary in daemon mode. This will start the local API server along with the daemon process:

# Run the binary with the API server enabledexport\$(cat .env | xargs) && ./target/spurredis_darwin_arm64 -api daemon

Ensure the environment variables are set correctly, especially `SPUR_REDIS_LOCAL_API_AUTH_TOKENS`, to use the API authentication.

API Usage Examples

Below are examples of how to interact with the API using curl:

Get context for an IP address

Replace your_auth_token with one of your valid API tokens and your_ip_address with the IP address you want to query.

curl -H "TOKEN: your_auth_token" http://localhost:PORT/v2/context/your_ip_address

Make sure to replace `PORT` with the actual port number your API server is listening on.

Configuration

The application can be configured through the following environment variables:

  • SPUR_REDIS_CHUNK_SIZE: Sets the chunk size for Redis operations. (default: 5000)
  • SPUR_REDIS_TTL: Sets the TTL (in hours) for Redis keys. (default: 24)
  • SPUR_REDIS_ADDR: Sets the Redis server address. (default: "localhost:6379")
  • SPUR_REDIS_PASS: Sets the Redis password. (default: "")
  • SPUR_REDIS_DB: Sets the Redis DB. (default: 0)
  • SPUR_REDIS_CONCURRENT_NUM: Sets the number of concurrent processes. (default: number of CPUs)
  • SPUR_REDIS_API_TOKEN: Sets the Spur API token. (Required)
  • SPUR_REDIS_FEED_TYPE: Sets the Spur feed type. (default: "anonymous")
  • SPUR_REDIS_REALTIME_ENABLED: Sets whether realtime feed is enabled. (default: false)
  • SPUR_REDIS_PORT: Sets the port for the application. (default: 8080)
  • SPUR_REDIS_CERT_FILE: Specifies the TLS Cert file. (default: "")
  • SPUR_REDIS_KEY_FILE: Specifies the TLS Key file. (default: "")
  • SPUR_REDIS_LOCAL_API_AUTH_TOKENS: Sets the local API Auth tokens. (Required; Tokens are comma separated)
  • SPUR_REDIS_IPV6_NETWORK_FEED_BETA: Also include data from IPv6 network info feeds (BETA). May increase resource requirements.

Please note: For SPUR_REDIS_API_TOKEN and SPUR_REDIS_LOCAL_API_AUTH_TOKENS, if these are not set, the application will not run.

Querying for the Data

docker exec -it redis redis-cli GET 1.2.3.4

Ensure all sensitive information and configurations are securely stored and not exposed unnecessarily.

About

Sample program to ingest Spur feeds into a redis database

Resources

Stars

1 star

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

feed-example-redis

This is a fully working sample program designed to ingest Spur feeds into a Redis database.

The Go binary provides 3 commands:

  1. daemon - Runs indefinitely, checks for the latest feed, and inserts it into Redis, updates using real-time data if your token supports it.
  2. insert - Inserts a feed file into Redis and exits.
  3. merge - Merges a real-time file into Redis and exits.

Requirements

To run this program, you will need:

  • Go installed on your machine.
  • Docker for managing containers.
  • A Spur token with access to feeds and optionally real-time data. This should be exposed in your environment as `SPUR_REDIS_API_TOKEN`.

System Requirements

  • Anonymous feeds require 5GB of memory.
  • Anonymous residential feeds require a minimum 18GB of memory.

Quickstart

To just run the app with a redis server, you can use the following Docker Compose file. This will start a Redis server and the feed-example-redis app. Please see the Configuration section for more information on the environment variables. NOTE: You will need to set the SPUR_REDIS_API_TOKEN environment variable to your Spur token.

version: '3'
services:
redis:
image: redis
ports:
- "6379:6379"
healthcheck:
test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ]
interval: 30s
timeout: 10s
retries: 5
spurredis:
image: spurintelligence/spurredis:latest
depends_on:
redis:
condition: service_healthy
ports:
- "8080:8080"
environment:
SPUR_REDIS_API_TOKEN: ${SPUR_REDIS_API_TOKEN}
SPUR_REDIS_FEED_TYPE: anonymous
SPUR_REDIS_CHUNK_SIZE: 5000
SPUR_REDIS_ADDR: redis:6379
SPUR_REDIS_LOCAL_API_AUTH_TOKENS: testtoken1,testtoken2

Then run the following command to test the API:

curl -vv -H "TOKEN: testtoken1" localhost:8080/v2/context/${YOUR_IP}| jq

Running

You have three options for running the application: local development with Docker, production with Docker Compose, or building the binary directly.

Option 1 - Local Development with Docker Compose

This builds a local Docker image with your changes and runs it with Docker Compose:

# Clone the repository
git clone https://github.com/spurintel/feed-example-redis.git
# Set the environment variables, minimum required is the Spur tokenexport SPUR_REDIS_API_TOKEN=your_spur_token
# Build and run with local changescd feed-example-redis
make run

Important: Make sure to export your environment variables (especially SPUR_REDIS_API_TOKEN) before running the make commands, as the Makefile passes these through to Docker Compose.

The local development setup automatically detects your platform (ARM64/AMD64) and builds the appropriate Docker image for your architecture.

Option 2 - Production with Docker Compose

This uses the published Docker image from Docker Hub:

# Set the environment variables, minimum required is the Spur tokenexport SPUR_REDIS_API_TOKEN=your_spur_token
# Run with production image
make run-prod

Option 3 - Build and run the binary directly

# Build the binarycd feed-example-redis
make
# Start a Redis server
docker run --rm -p 6379:6379 --name redis redis:latest
# Run the binary in daemon mode, assumes you have your token and other configurations set in a .env fileexport$(cat .env | xargs)&& ./target/spurredis_darwin_arm64 daemon

Available Make Targets

Run make help to see all available targets with descriptions, or use these common ones:

  • make run - Local development (builds local Docker image and runs with Docker Compose)
  • make run-local - Same as make run
  • make run-prod - Production (uses published Docker image)
  • make build-local - Build local Docker image only
  • make clean - Remove build artifacts and local Docker image
  • make bin - Build native binary for your platform
  • make bin-linux - Build Linux binary
  • make test - Run tests
  • make format - Format code
  • make lint - Run linter

Configuring and Running the API Locally

To run the API server locally, use the `-api` flag when starting the binary in daemon mode. This will start the local API server along with the daemon process:

# Run the binary with the API server enabledexport\$(cat .env | xargs) && ./target/spurredis_darwin_arm64 -api daemon

Ensure the environment variables are set correctly, especially `SPUR_REDIS_LOCAL_API_AUTH_TOKENS`, to use the API authentication.

API Usage Examples

Below are examples of how to interact with the API using curl:

Get context for an IP address

Replace your_auth_token with one of your valid API tokens and your_ip_address with the IP address you want to query.

curl -H "TOKEN: your_auth_token" http://localhost:PORT/v2/context/your_ip_address

Make sure to replace `PORT` with the actual port number your API server is listening on.

Configuration

The application can be configured through the following environment variables:

  • SPUR_REDIS_CHUNK_SIZE: Sets the chunk size for Redis operations. (default: 5000)
  • SPUR_REDIS_TTL: Sets the TTL (in hours) for Redis keys. (default: 24)
  • SPUR_REDIS_ADDR: Sets the Redis server address. (default: "localhost:6379")
  • SPUR_REDIS_PASS: Sets the Redis password. (default: "")
  • SPUR_REDIS_DB: Sets the Redis DB. (default: 0)
  • SPUR_REDIS_CONCURRENT_NUM: Sets the number of concurrent processes. (default: number of CPUs)
  • SPUR_REDIS_API_TOKEN: Sets the Spur API token. (Required)
  • SPUR_REDIS_FEED_TYPE: Sets the Spur feed type. (default: "anonymous")
  • SPUR_REDIS_REALTIME_ENABLED: Sets whether realtime feed is enabled. (default: false)
  • SPUR_REDIS_PORT: Sets the port for the application. (default: 8080)
  • SPUR_REDIS_CERT_FILE: Specifies the TLS Cert file. (default: "")
  • SPUR_REDIS_KEY_FILE: Specifies the TLS Key file. (default: "")
  • SPUR_REDIS_LOCAL_API_AUTH_TOKENS: Sets the local API Auth tokens. (Required; Tokens are comma separated)
  • SPUR_REDIS_IPV6_NETWORK_FEED_BETA: Also include data from IPv6 network info feeds (BETA). May increase resource requirements.

Please note: For SPUR_REDIS_API_TOKEN and SPUR_REDIS_LOCAL_API_AUTH_TOKENS, if these are not set, the application will not run.

Querying for the Data

docker exec -it redis redis-cli GET 1.2.3.4

Ensure all sensitive information and configurations are securely stored and not exposed unnecessarily.

About

Sample program to ingest Spur feeds into a redis database

Resources

Stars

1 star

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

feed-example-redis

This is a fully working sample program designed to ingest Spur feeds into a Redis database.

The Go binary provides 3 commands:

  1. daemon - Runs indefinitely, checks for the latest feed, and inserts it into Redis, updates using real-time data if your token supports it.
  2. insert - Inserts a feed file into Redis and exits.
  3. merge - Merges a real-time file into Redis and exits.

Requirements

To run this program, you will need:

  • Go installed on your machine.
  • Docker for managing containers.
  • A Spur token with access to feeds and optionally real-time data. This should be exposed in your environment as `SPUR_REDIS_API_TOKEN`.

System Requirements

  • Anonymous feeds require 5GB of memory.
  • Anonymous residential feeds require a minimum 18GB of memory.

Quickstart

To just run the app with a redis server, you can use the following Docker Compose file. This will start a Redis server and the feed-example-redis app. Please see the Configuration section for more information on the environment variables. NOTE: You will need to set the SPUR_REDIS_API_TOKEN environment variable to your Spur token.

version: '3'
services:
redis:
image: redis
ports:
- "6379:6379"
healthcheck:
test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ]
interval: 30s
timeout: 10s
retries: 5
spurredis:
image: spurintelligence/spurredis:latest
depends_on:
redis:
condition: service_healthy
ports:
- "8080:8080"
environment:
SPUR_REDIS_API_TOKEN: ${SPUR_REDIS_API_TOKEN}
SPUR_REDIS_FEED_TYPE: anonymous
SPUR_REDIS_CHUNK_SIZE: 5000
SPUR_REDIS_ADDR: redis:6379
SPUR_REDIS_LOCAL_API_AUTH_TOKENS: testtoken1,testtoken2

Then run the following command to test the API:

curl -vv -H "TOKEN: testtoken1" localhost:8080/v2/context/${YOUR_IP}| jq

Running

You have three options for running the application: local development with Docker, production with Docker Compose, or building the binary directly.

Option 1 - Local Development with Docker Compose

This builds a local Docker image with your changes and runs it with Docker Compose:

# Clone the repository
git clone https://github.com/spurintel/feed-example-redis.git
# Set the environment variables, minimum required is the Spur tokenexport SPUR_REDIS_API_TOKEN=your_spur_token
# Build and run with local changescd feed-example-redis
make run

Important: Make sure to export your environment variables (especially SPUR_REDIS_API_TOKEN) before running the make commands, as the Makefile passes these through to Docker Compose.

The local development setup automatically detects your platform (ARM64/AMD64) and builds the appropriate Docker image for your architecture.

Option 2 - Production with Docker Compose

This uses the published Docker image from Docker Hub:

# Set the environment variables, minimum required is the Spur tokenexport SPUR_REDIS_API_TOKEN=your_spur_token
# Run with production image
make run-prod

Option 3 - Build and run the binary directly

# Build the binarycd feed-example-redis
make
# Start a Redis server
docker run --rm -p 6379:6379 --name redis redis:latest
# Run the binary in daemon mode, assumes you have your token and other configurations set in a .env fileexport$(cat .env | xargs)&& ./target/spurredis_darwin_arm64 daemon

Available Make Targets

Run make help to see all available targets with descriptions, or use these common ones:

  • make run - Local development (builds local Docker image and runs with Docker Compose)
  • make run-local - Same as make run
  • make run-prod - Production (uses published Docker image)
  • make build-local - Build local Docker image only
  • make clean - Remove build artifacts and local Docker image
  • make bin - Build native binary for your platform
  • make bin-linux - Build Linux binary
  • make test - Run tests
  • make format - Format code
  • make lint - Run linter

Configuring and Running the API Locally

To run the API server locally, use the `-api` flag when starting the binary in daemon mode. This will start the local API server along with the daemon process:

# Run the binary with the API server enabledexport\$(cat .env | xargs) && ./target/spurredis_darwin_arm64 -api daemon

Ensure the environment variables are set correctly, especially `SPUR_REDIS_LOCAL_API_AUTH_TOKENS`, to use the API authentication.

API Usage Examples

Below are examples of how to interact with the API using curl:

Get context for an IP address

Replace your_auth_token with one of your valid API tokens and your_ip_address with the IP address you want to query.

curl -H "TOKEN: your_auth_token" http://localhost:PORT/v2/context/your_ip_address

Make sure to replace `PORT` with the actual port number your API server is listening on.

Configuration

The application can be configured through the following environment variables:

  • SPUR_REDIS_CHUNK_SIZE: Sets the chunk size for Redis operations. (default: 5000)
  • SPUR_REDIS_TTL: Sets the TTL (in hours) for Redis keys. (default: 24)
  • SPUR_REDIS_ADDR: Sets the Redis server address. (default: "localhost:6379")
  • SPUR_REDIS_PASS: Sets the Redis password. (default: "")
  • SPUR_REDIS_DB: Sets the Redis DB. (default: 0)
  • SPUR_REDIS_CONCURRENT_NUM: Sets the number of concurrent processes. (default: number of CPUs)
  • SPUR_REDIS_API_TOKEN: Sets the Spur API token. (Required)
  • SPUR_REDIS_FEED_TYPE: Sets the Spur feed type. (default: "anonymous")
  • SPUR_REDIS_REALTIME_ENABLED: Sets whether realtime feed is enabled. (default: false)
  • SPUR_REDIS_PORT: Sets the port for the application. (default: 8080)
  • SPUR_REDIS_CERT_FILE: Specifies the TLS Cert file. (default: "")
  • SPUR_REDIS_KEY_FILE: Specifies the TLS Key file. (default: "")
  • SPUR_REDIS_LOCAL_API_AUTH_TOKENS: Sets the local API Auth tokens. (Required; Tokens are comma separated)
  • SPUR_REDIS_IPV6_NETWORK_FEED_BETA: Also include data from IPv6 network info feeds (BETA). May increase resource requirements.

Please note: For SPUR_REDIS_API_TOKEN and SPUR_REDIS_LOCAL_API_AUTH_TOKENS, if these are not set, the application will not run.

Querying for the Data

docker exec -it redis redis-cli GET 1.2.3.4

Ensure all sensitive information and configurations are securely stored and not exposed unnecessarily.

About

Sample program to ingest Spur feeds into a redis database

Resources

Stars

1 star

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Repository files navigation

feed-example-redis

This is a fully working sample program designed to ingest Spur feeds into a Redis database.

The Go binary provides 3 commands:

  1. daemon - Runs indefinitely, checks for the latest feed, and inserts it into Redis, updates using real-time data if your token supports it.
  2. insert - Inserts a feed file into Redis and exits.
  3. merge - Merges a real-time file into Redis and exits.

Requirements

To run this program, you will need:

  • Go installed on your machine.
  • Docker for managing containers.
  • A Spur token with access to feeds and optionally real-time data. This should be exposed in your environment as `SPUR_REDIS_API_TOKEN`.

System Requirements

  • Anonymous feeds require 5GB of memory.
  • Anonymous residential feeds require a minimum 18GB of memory.

Quickstart

To just run the app with a redis server, you can use the following Docker Compose file. This will start a Redis server and the feed-example-redis app. Please see the Configuration section for more information on the environment variables. NOTE: You will need to set the SPUR_REDIS_API_TOKEN environment variable to your Spur token.

version: '3'
services:
redis:
image: redis
ports:
- "6379:6379"
healthcheck:
test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ]
interval: 30s
timeout: 10s
retries: 5
spurredis:
image: spurintelligence/spurredis:latest
depends_on:
redis:
condition: service_healthy
ports:
- "8080:8080"
environment:
SPUR_REDIS_API_TOKEN: ${SPUR_REDIS_API_TOKEN}
SPUR_REDIS_FEED_TYPE: anonymous
SPUR_REDIS_CHUNK_SIZE: 5000
SPUR_REDIS_ADDR: redis:6379
SPUR_REDIS_LOCAL_API_AUTH_TOKENS: testtoken1,testtoken2

Then run the following command to test the API:

curl -vv -H "TOKEN: testtoken1" localhost:8080/v2/context/${YOUR_IP}| jq

Running

You have three options for running the application: local development with Docker, production with Docker Compose, or building the binary directly.

Option 1 - Local Development with Docker Compose

This builds a local Docker image with your changes and runs it with Docker Compose:

# Clone the repository
git clone https://github.com/spurintel/feed-example-redis.git
# Set the environment variables, minimum required is the Spur tokenexport SPUR_REDIS_API_TOKEN=your_spur_token
# Build and run with local changescd feed-example-redis
make run

Important: Make sure to export your environment variables (especially SPUR_REDIS_API_TOKEN) before running the make commands, as the Makefile passes these through to Docker Compose.

The local development setup automatically detects your platform (ARM64/AMD64) and builds the appropriate Docker image for your architecture.

Option 2 - Production with Docker Compose

This uses the published Docker image from Docker Hub:

# Set the environment variables, minimum required is the Spur tokenexport SPUR_REDIS_API_TOKEN=your_spur_token
# Run with production image
make run-prod

Option 3 - Build and run the binary directly

# Build the binarycd feed-example-redis
make
# Start a Redis server
docker run --rm -p 6379:6379 --name redis redis:latest
# Run the binary in daemon mode, assumes you have your token and other configurations set in a .env fileexport$(cat .env | xargs)&& ./target/spurredis_darwin_arm64 daemon

Available Make Targets

Run make help to see all available targets with descriptions, or use these common ones:

  • make run - Local development (builds local Docker image and runs with Docker Compose)
  • make run-local - Same as make run
  • make run-prod - Production (uses published Docker image)
  • make build-local - Build local Docker image only
  • make clean - Remove build artifacts and local Docker image
  • make bin - Build native binary for your platform
  • make bin-linux - Build Linux binary
  • make test - Run tests
  • make format - Format code
  • make lint - Run linter

Configuring and Running the API Locally

To run the API server locally, use the `-api` flag when starting the binary in daemon mode. This will start the local API server along with the daemon process:

# Run the binary with the API server enabledexport\$(cat .env | xargs) && ./target/spurredis_darwin_arm64 -api daemon

Ensure the environment variables are set correctly, especially `SPUR_REDIS_LOCAL_API_AUTH_TOKENS`, to use the API authentication.

API Usage Examples

Below are examples of how to interact with the API using curl:

Get context for an IP address

Replace your_auth_token with one of your valid API tokens and your_ip_address with the IP address you want to query.

curl -H "TOKEN: your_auth_token" http://localhost:PORT/v2/context/your_ip_address

Make sure to replace `PORT` with the actual port number your API server is listening on.

Configuration

The application can be configured through the following environment variables:

  • SPUR_REDIS_CHUNK_SIZE: Sets the chunk size for Redis operations. (default: 5000)
  • SPUR_REDIS_TTL: Sets the TTL (in hours) for Redis keys. (default: 24)
  • SPUR_REDIS_ADDR: Sets the Redis server address. (default: "localhost:6379")
  • SPUR_REDIS_PASS: Sets the Redis password. (default: "")
  • SPUR_REDIS_DB: Sets the Redis DB. (default: 0)
  • SPUR_REDIS_CONCURRENT_NUM: Sets the number of concurrent processes. (default: number of CPUs)
  • SPUR_REDIS_API_TOKEN: Sets the Spur API token. (Required)
  • SPUR_REDIS_FEED_TYPE: Sets the Spur feed type. (default: "anonymous")
  • SPUR_REDIS_REALTIME_ENABLED: Sets whether realtime feed is enabled. (default: false)
  • SPUR_REDIS_PORT: Sets the port for the application. (default: 8080)
  • SPUR_REDIS_CERT_FILE: Specifies the TLS Cert file. (default: "")
  • SPUR_REDIS_KEY_FILE: Specifies the TLS Key file. (default: "")
  • SPUR_REDIS_LOCAL_API_AUTH_TOKENS: Sets the local API Auth tokens. (Required; Tokens are comma separated)
  • SPUR_REDIS_IPV6_NETWORK_FEED_BETA: Also include data from IPv6 network info feeds (BETA). May increase resource requirements.

Please note: For SPUR_REDIS_API_TOKEN and SPUR_REDIS_LOCAL_API_AUTH_TOKENS, if these are not set, the application will not run.

Querying for the Data

docker exec -it redis redis-cli GET 1.2.3.4

Ensure all sensitive information and configurations are securely stored and not exposed unnecessarily.

About

Sample program to ingest Spur feeds into a redis database

Resources

Stars

1 star

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages