Github user jpeach commented on a diff in the pull request: https://github.com/apache/trafficserver/pull/560#discussion_r59384993 --- Diff: plugins/experimental/acme/acme.c --- @@ -0,0 +1,347 @@ +/** @file + +@section license + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <ctype.h> +#include <string.h> +#include <sys/types.h> +#include <unistd.h> +#include <getopt.h> +#include <sys/stat.h> + +#include "ts/ts.h" +#include "ts/ink_platform.h" +#include "ts/ink_defs.h" + +static const char PLUGIN_NAME[] = "acme"; +static const char ACME_WK_PATH[] = ".well-known/acme-challenge/"; +static const char ACME_OK_RESP[] = "HTTP/1.1 200 OK\r\nContent-Type: application/jose\r\nCache-Control: no-cache\r\n"; +static const char ACME_DENIED_RESP[] = "HTTP/1.1 404 Not Found\r\nContent-Type: application/jose\r\nCache-Control: no-cache\r\n"; + +#define MAX_PATH_LEN 4096 + +/* This should hold all configurations going forward. */ +typedef struct AcmeConfig_t { + char *proof; +} AcmeConfig; +AcmeConfig gConfig; + +/* State used for the intercept plugin. ToDo: Can this be improved ? */ +typedef struct AcmeState_t { + TSVConn net_vc; + TSVIO read_vio; + TSVIO write_vio; + + TSIOBuffer req_buffer; + TSIOBuffer resp_buffer; + TSIOBufferReader resp_reader; + + int output_bytes; + int fd; + struct stat stat_buf; +} AcmeState; + + +inline static AcmeState * +make_acme_state() +{ + AcmeState *state = (AcmeState *)TSmalloc(sizeof(AcmeState)); + + memset(state, 0, sizeof(AcmeState)); + state->fd = -1; + + return state; +} + +/* Create a safe pathname to the proof-type file, the destination must be sufficiently large. */ +static int --- End diff -- Better to return ``ssize_t`` here to indicate a length or error.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---