JosiahWI commented on code in PR #9884:
URL: https://github.com/apache/trafficserver/pull/9884#discussion_r1235488785


##########
cmake/ConfigureTransparentProxy.cmake:
##########
@@ -0,0 +1,74 @@
+#######################
+#
+#  Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license
+#  agreements.  See the NOTICE file distributed with this work for additional 
information regarding
+#  copyright ownership.  The ASF licenses this file to you 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.
+#
+#######################
+
+# ConfigureTransparentProxy.cmake
+#
+# The following variables should be set
+#
+#     ENABLE_TPROXY to one of AUTO, NO, or a number
+#     TS_USE_POSIX_CAP to a boolean value
+#
+# This will define the following variables
+#
+#     TS_USE_TPROXY
+#     TS_IP_TRANSPARENT
+#
+
+set(TS_IP_TRANSPARENT 0)
+
+if(ENABLE_TPROXY STREQUAL "NO")
+    set(TS_USE_TPROXY FALSE)
+    return()
+endif()
+
+if(NOT TS_USE_POSIX_CAP)
+    if(ENABLE_TPROXY STREQUAL "AUTO")
+        set(TS_USE_TPROXY FALSE)
+    else()
+        message(FATAL_ERROR "ENABLE_TPROXY requires POSIX capabilities.")
+    endif()
+    return()
+endif()
+
+if(ENABLE_TPROXY STREQUAL "FORCE")
+    set(TS_USE_TPROXY TRUE)
+    set(TS_IP_TRANSPARENT 19)
+    return()
+endif()
+
+if(ENABLE_TPROXY MATCHES "([0-9]+)")
+    set(TS_USE_TPROXY TRUE)
+    set(TS_IP_TRANSPARENT ${CMAKE_MATCH_1})
+    return()
+endif()
+
+# If the read fails, it will print out a confusing error. This
+# is to make it clear why the error is happening in that case.
+message("ENABLE_TPROXY enabled, looking for value in /usr/include/linux/in.h")
+file(READ "/usr/include/linux/in.h" HEADER_CONTENTS)
+if(HEADER_CONTENTS MATCHES "#define[ \t]+IP_TRANSPARENT[ \t]+([0-9]+)")
+    set(TS_USE_TPROXY TRUE)
+    set(TS_IP_TRANSPARENT ${CMAKE_MATCH_1})
+else()
+    if(ENABLE_TPROXY STREQUAL "AUTO")
+        set(TS_USE_TPROXY FALSE)
+    else()
+        message(FATAL_ERROR "ENABLE_TPROXY on but sockopt value not found")

Review Comment:
   The file name is printed out just before, but stating the symbol name is a 
great idea.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to