Replicating Fastly Varnish locally

Overview

Fastly VCL Interpreters in Rust

A tree-walk interpreter for Fastly VCL

Install project

  • Install rust - curl https://sh.rustup.rs -sSf | sh
  • Clone project - git clone https://github.com/JakeChampion/vcl-local.git && cd vcl-local
  • Build project - cargo build
  • Test project - cargo test
  • Install project cargo install --path .
  • Try out new command - vcl-local examples/polyfill/main.vcl --show-ast

Examples

Now consider hello.vcl

log "hello world";

We can tokenize this with

cargo run --release --quiet -- hello.vcl --show-tokens

Which gives output

tokens: [
    Token { ty: Log, lexeme: "log", literal: None, line: 1, col: 2},
    Token { ty: String, lexeme: ""hello world"", literal: Some(Str("hello world")), line: 1, col: 16},
    Token { ty: Semicolon, lexeme: ";", literal: None, line: 1, col: 17},
    Token { ty: Eof, lexeme: "", literal: None, line: 1, col: 17},
]

We can show the AST with

cargo run --release --quiet -- hello.vcl --show-ast

Which gives

AST: [
    Log(
        Literal(
            String(
                "hello world",
            ),
        ),
    ),
]

TODO

Scanner

  • Add comments to the scan result

Parser

  • Pragmas
  • Macros
  • ACL
  • Includes
  • string concat without requiring + sign. e.g. - set req.http.a = "url:"req.url;
  • heredoc syntax for long strings
  • short strings need percent decoding
  • long strings do not need percent decoding
  • typed tables
  • subfield lookup using colon -- set client.identity = req.http.cookie:user_id;

Interpreter

  • The integer variants of the +=, -=, and *= operators wrap around as if they were unsigned 64-bit integers.
  • FLOAT arithmetic has special cases for operands which are NaN: Arithmetic operators evaluate to NaN when either operand is NaN.
  • fastly.error = "EDOM" when Domain error. This occurs for a mathematical function which is not defined for a particular value; formally, that value is not considered part of its input domain. For example, division by zero, or var.x %= 5; where var.x is a floating point infinity.
You might also like...
Download pdbs from symbol servers and cache locally, parse symbol paths from env vars

symsrv This crate lets you download and cache pdb files from symbol servers, according to the rules from the _NT_SYMBOL_PATH environment variable. It

Kinda functional block engine for testing bundles on jito-solana locally

Half Baked Block Engine About This is a half-baked block engine. It can be used for testing bundles running through jito-solana. Shortcomings The bare

ABQ is a universal test runner that runs test suites in parallel. It’s the best tool for splitting test suites into parallel jobs locally or on CI

🌐 abq.build   🐦 @rwx_research   πŸ’¬ discord   πŸ“š documentation ABQ is a universal test runner that runs test suites in parallel. It’s the best tool f

Believe in AI democratization. llama for nodejs backed by llama-rs, work locally on your laptop CPU. support llama/alpaca model.
Believe in AI democratization. llama for nodejs backed by llama-rs, work locally on your laptop CPU. support llama/alpaca model.

llama-node Large Language Model LLaMA on node.js This project is in an early stage, the API for nodejs may change in the future, use it with caution.

Multi-platform desktop app to download and run Large Language Models(LLM) locally in your computer.
Multi-platform desktop app to download and run Large Language Models(LLM) locally in your computer.

Multi-platform desktop app to download and run Large Language Models(LLM) locally in your computer πŸ”— Download | Give it a Star ⭐ | Share it on Twitte

Open-source Rewind.ai clone written in Rust and Vue running 100% locally with whisper.cpp

mind-overflow Open-source Rewind.AI clone built with Tauri and Vue. Leverages whisper.cpp for Speech-to-Text and (wip: llama.cpp for Text generation a

Attempt to summarize text from `stdin`, using a large language model (locally and offline), to `stdout`

summarize-cli Attempt to summarize text from stdin, using a large language model (locally and offline), to stdout. cargo build --release target/releas

Owner
Jake Champion
Jake Champion
Make and use playgrounds locally.

cargo playground Cargo playground opens a local playground in the editor of your choice. Install You can install it directly using cargo $ cargo insta

null 18 Jan 3, 2023
A utility that can download JavaScript and TypeScript module graphs and store them locally in a special zip file.

eszip A utility that can download JavaScript and TypeScript module graphs and store them locally in a special zip file. To create a new archive: > esz

Deno Land 162 Dec 24, 2022
Test social media cards locally

Share Preview Test social media cards locally Description Preview and debug websites metadata tags for social media share. Third Party Packages Distri

Rafael Mardojai CM 65 Dec 25, 2022
Run Github Actions workflows locally or on a custom backend

gha-runner runs Github Actions workflows. You can run workflows locally, or extend gha-runner with custom backends to run workflows elsewhere (e.g. Pe

Pernosco 12 Dec 27, 2022
Desktop launcher to install and use Holochain apps locally

Holochain Launcher A cross-platform executable that launches a local Holochain conductor, and installs and opens apps. Feedback is immensely welcome i

Holochain 58 Dec 30, 2022
Merge together and efficiently time-sort compressed .pcap files stored in AWS S3 object storage (or locally) to stdout for pipelined processing.

Merge together and efficiently time-sort compressed .pcap files stored in AWS S3 object storage (or locally) to stdout for pipelined processing. High performance and parallel implementation for > 10 Gbps playback throughput with large numbers of files (~4k).

null 4 Aug 19, 2022
sg = Steam Guard, access sg verification code locally.

Steam Guard CLI Access your Steam Guard token locally. Credit https://github.com/steevp/UpdogFarmer/blob/master/app/src/main/java/com/steevsapps/idled

Vanilla's Lab 7 Nov 10, 2022
Dr-dotnet - 🩺 One-click diagnosis of your dotnet applications. Works both locally or remotely as a web service

Dr-dotnet - ?? One-click diagnosis of your dotnet applications. Works both locally or remotely as a web service. Based on the lowest level dotnet profiling APIs and using the rust language ?? for a minimal runtime penalty.

Olivier Giniaux 25 Dec 17, 2022
Testing interactions with other NFT projects locally is difficult

Terra NFT Stub contract Testing interactions with other NFT projects locally is difficult. Terra NFT Stub makes things a bit easier by providing a con

smaster0517 5 Apr 6, 2022
Mac App/CLI that automatically adds project logos to your locally cloned GitHub repos

Download the app Automatically adds project logos to your locally cloned GitHub repos. Youtube Video This repository contains the source code for the

Sam Denty 365 Dec 25, 2022